Thomas DuBuisson wrote:
Bardur Arantsson <s...@scientician.net> wrote:
...
      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.


Excellent, thanks. I was probably too tired or annoyed when I wrote that code. I sorta-kinda-knew I must have been doing *something* wrong :).

I'll retry with a more reasonable delay tomorrow.

Cheers,

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to