Re: Interrupting a socket waiting on nlAcceptConnection() or nlRead()?


[ Follow Ups ] [ Post Followup ] [ Back To Message Board ]

Posted by Phil Frisbie, Jr. on February 07, 2006 at 14:15:57:

In Reply to: Interrupting a socket waiting on nlAcceptConnection() or nlRead()? posted by David on February 06, 2006 at 20:49:40:

: If possible, I'd like to use threads and blocking IO. However, I'd also like to be able to interrupt that IO from another thread so that I can gracefully terminate the connection. I'm running a server thread that spawns multiple connection threads. I ran into a problem where a server thread is waiting in nlAcceptConnection() and I'd like to stop that server. If I use nlClose() on that socket from another thread, it hangs (in a deadlock I assume), and nlShutdown() seems to free up that socket but isn't really a viable solution.

This statement confuses me. Why is nlShutdown() not viable? I cannot think of any reason to unblock a single thread unless you are going to shut down the server, and so you would, of course, call nlShutdown().

I will, however, look into why calling nlClose() results in a deadlock, since that SHOULD work anyway.

: I can implement this functionality using non-blocking IO, but then I lose the simplicity of blocking IO. Any pointers? I haven't really delved into the code to see if I can modify anything.

I still would like to know WHY you think you need to unblock a single thread when you are NOT shutting down??

Phil


Follow Ups:


Post a Followup

Name:
E-Mail:

Subject:

Comments:



[ Follow Ups ] [ Post Followup ] [ Back To Message Board ]