[Haskell] Help needed interrupting accepting a network connection

Cat Dancer haskell at catdancer.ws
Sat Dec 2 18:39:11 EST 2006

On 12/2/06, Chris Kuklewicz <haskell at list.mightyreason.com> wrote:
> Hi, I have taken a crack at this.  The best thing would be not to use the
> asynchronous exceptions to signal the thread that calls accept.

I'd certainly be most happy not to use asynchronous exceptions as the
signalling mechanism, but how would you break out of the accept,
except by receiving an asynchronous exception?

> But a few minor changes gets closer to what you want.  First, the main problem
> you claim to run into is
> > Except that, whoops, the "takeMVar" in the accept thread code which updates the
> > childrenDone" MVar is also interruptible.  So now I'm getting an
> > interruption right where I don't want it, when I'm updating my data
> > structure.
> Short version: There is no problem because it will not become interruptible.
> Long version:  The takeMVar unblocks exceptions only if it must
> stop and wait for the MVar.  The MVar is only taken by this command/thread and
> during graceful shutdown after this thread is dead.  So this MVar should never
> be in contention (and in theory does not *need* to be a locked MVar, and an
> IORef would do).

Gosh, I think you're right.

More information about the Haskell mailing list