On Fri, 2009-10-23 at 10:12 +1100, Bojan Smojver wrote:
> Slower, but safer attached (not even compiled, so could be utterly
> bogus).

BTW, this approach still isn't safe. The socket can disappear (i.e. be
closed) between the test and the closing (or shutdown()). Worse, with
shutdown(), we could attempt to shut down the wrong FD, if we have fast
succession of close()/open() in various threads.

I think the correct approach would be to make sure that we actually
suspend worker threads before we do this. In other words, we send a
signal to each worker thread and their signal handler calls
sigsuspend(), thus waiting to be resumed. We also set thread specific
variables, notifying the listener thread about workers that have been
suspended.

Once the listener thread knows this (i.e. that all workers are
suspended), it shuts the sockets down and resumes the worker threads by
sending them a signal.

Workable?

-- 
Bojan

Reply via email to