threads and blocking functions
Well I've come across a problem in my coding, not a huge one, but an annoying one for sure.
Basically I have a multi-threaded server, most of the threads consist of listen threads for the people who've logged in. And another thread that everyones input is put into a queue, and the thread excutes their input.
Now I've come to a problem trying to make a kick function, and barely managed to make a log off function, but its still buggy too.
Each player has a loop where it gets their input, puts it on the queue, and then blocks the loop waiting for more input.
But then the excution queue see's that they are trying to quit, and closes their file descriptors.
How ever at this point the thread devoted to the player who is trying to quit has blocked excution, and waits for one more input... of anything, and THEN they are logged off.
So the question is... is there any way to unblock a lowe level "read(FD,..)" funtion?
about the only thing I can think of is to start messing with the thread_canceling, fucntions...
I'm using c++ ... and really just looking for a way for one thread to unblock a blocking function of another thread, particularly a read file descriptor function....
Kris
|