[Haskell-cafe] Race conditions with threadWait(Read/Write) and closeFdWith
Leon Smith
leon.p.smith at gmail.com
Tue Sep 2 10:59:40 UTC 2014
On Mon, Sep 1, 2014 at 7:13 PM, John Lato <jwlato at gmail.com> wrote:
> So what should happen in your situation is that, when a separate thread
> closes the fd, threadWaitRead will throw an exception promptly, not
> continue to wait on a now-closed fd.
>
Right, which is what would happen most of the time. But in the race
condition I'm pointing out, the thread yields *before* the call to
threadWaitRead, so there is no interest yet registered in the file
descriptor, so closeFdWith does not raise an exception. When the
thread that calls threadWaitRead is resumed, it ends up waiting on an
entirely different descriptor that happens to share the same index as the
old descriptor.
Best,
Leon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140902/cc31ecc1/attachment.html>
More information about the Haskell-Cafe
mailing list