
On 02-09-2014 14:01, John Lato wrote:
Have you actually observed this behavior? I suspect that the thread will never yield between readMVar and threadWaitRead because there are no allocations. I suppose an async exception could arise, so it might be correct to run that line with exceptions masked.
As I understand it, the problem isn't limited to the thread yielding. If the program is running on more than one capability, it's conceivable that another thread running on another capability will (a) close that Fd and (b) open another Fd that will receive the same value, both between the readMVar and the threadWaitRead calls. I don't see how one could allow concurrent readers and "closers" without leaving this small opening. The best workaround I can think of is to create a blocking close operation that waits for readers using a semaphore. Cheers, -- Felipe.