[Haskell-cafe] Re: sendfile leaking descriptors on Linux?
Bardur Arantsson
spam at scientician.net
Fri Feb 5 02:56:12 EST 2010
Jeremy Shaw wrote:
> Actually,
>
> We should start by testing if native sendfile leaks file descriptors even
> when the whole file is sent. We have a test suite, but I am not sure if it
> tests for file handle leaking...
>
I should have posted this earlier, but the exact message I'm seeing in
the case where the Bad Client disconnects is this:
hums: Network.Socket.SendFile.Linux: resource vanished (Broken pipe)
Oddly, I haven't been able to reproduce this using a wget client with a
^C during transfer. When I "disconnect" wget with ^C or "pkill wget" or
even "pkill -9 wget", I get this message:
hums: Network.Socket.SendFile.Linux: resource vanished (Connection
reset by peer)
(and no leak, as observed by "lsof | grep hums").
So there appears to be some vital difference between the handling of the
two cases.
Another observation which may be useful:
Before the sendfile' API change (Handle -> FilePath) in sendfile-0.6.x,
my code used "withFile" to open the file and to ensure that it was
closed. So it seems that withBinaryFile *should* also be fine. Unless
the "Broken pipe" error somehow escapes the scope without causing a "close".
I don't have time to dig more right now, but I'll try to see if I can
find out more later.
Cheers,
More information about the Haskell-Cafe
mailing list