
Bardur Arantsson
... then do errno <- getErrno if errno == eAGAIN then do threadDelay 100 sendfile out_fd in_fd poff bytes else throwErrno "Network.Socket.SendFile.Linux" else return (fromIntegral sbytes)
That is, I removed the threadWaitWrite in favor of just adding a "threadDelay 100" when eAGAIN is encountered.
With this code, I cannot provoke the leak.
Unfortunately this isn't really a solution -- the CPU is pegged at ~50% when I do this and it's not exactly elegant to have a hardcoded 100 ms delay in there. :)
I don't think it matters wrt the desired final solution, but this is NOT a 100 ms delay. It is a 0.1 ms delay, which is less than a GHC time slice and as such is basically a tight loop. If you use a reasonable value for the delay you will probably see the CPU being almost completely idle. Thomas