LWP_CreateThread counterpart to stop thread execution?
Posted: Fri Jun 10, 2011 8:19 am
I'm writing an ftp server and I've run into a problem. If the client waits too long between messages, I want to end the connection. As of now my program is set up like this:
Main thread (for controller input) spawns a server thread
Server thread listens for new connections and spawns threads for new clients
Client threads run net_read() in a loop, which blocks until data is received
Since net_read() blocks, I can't tell from within the client threads if I should end the connection until more data comes in so it unblocks, which could be never. So my solution was to create a watchdog thread that will periodically check to see when the last time data was received in each child thread, and if it was more than X minutes ago, net_close() the socket and "delete" the thread. But I can't seem to find a function to completely get rid of the thread, only to suspend it, unless it exits on its own accord.
Is there such a function? If not, what would be the most elegant solution?
Main thread (for controller input) spawns a server thread
Server thread listens for new connections and spawns threads for new clients
Client threads run net_read() in a loop, which blocks until data is received
Since net_read() blocks, I can't tell from within the client threads if I should end the connection until more data comes in so it unblocks, which could be never. So my solution was to create a watchdog thread that will periodically check to see when the last time data was received in each child thread, and if it was more than X minutes ago, net_close() the socket and "delete" the thread. But I can't seem to find a function to completely get rid of the thread, only to suspend it, unless it exits on its own accord.
Is there such a function? If not, what would be the most elegant solution?