[Haskell-cafe] Re: sendfile leaking descriptors on Linux?

Donn Cave donn at avvanta.com
Sun Feb 21 12:50:30 EST 2010


Quoth Bardur Arantsson <spam at scientician.net>,
> Taru Karttunen wrote:

>> Excerpts from Bardur Arantsson's message of Wed Feb 17 21:27:07 +0200 2010:
>>> For sendfile, a timeout of 1 second would probably be fine. The *ONLY* 
>>> purpose of threadWaitWrite in the sendfile code is to avoid busy-waiting 
>>> on EAGAIN from the native sendfile.
>> 
>> Of course this will kill connections for all clients that may have a
>> two second network hickup.
>> 
>
> I'm not talking about killing the connection. I'm talking about retrying 
> sendfile() if threadWaitWrite has been waiting for more than 1 second.
>
> If the connection *has already been closed* (as detected by the OS), 
> then sendfile() will fail with EBADF, and we're good.
...
> I don't see how that would lead to anything like what you describe.

If I understand correctly, we're talking about what it means for the
OS to detect a closed connection.

The proposal I think was to change the socket options to add keepalive,
and to set a short timeout.  This will indeed allow the OS to discover
connections that didn't properly close, but are effectively closed in
the sense that they are no use any more - disconnected cable, or it
sounds like the PS3 may routinely do this out of negligence.

The problem is that this definition of `closed' is, precisely,
`failed to respond within 2 seconds.'  If there is no observable
difference between a connection that has been abandoned by the PS3,
and a connection that just suffered a momentary lapse, then there's
no way to catch the former without making connections more fragile.

	Donn Cave
	donn at avvanta.com



More information about the Haskell-Cafe mailing list