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

Taru Karttunen taruti at taruti.net
Wed Feb 17 03:36:50 EST 2010


Excerpts from Bardur Arantsson's message of Tue Feb 16 23:48:14 +0200 2010:
> > This cannot be fixed in the sendfile library, it is a 
> > feature of TCP that connections may linger for a long
> > time unless explicit timeouts are used.
> 
> The problem is that the sendfile library *doesn't* wake
> up when the connection is terminated (because of threadWaitWrite)
> -- it doesn't matter what the timeout is.

Even server code without sendfile has the same issue since
all writing to sockets ends up using threadWaitWrite.

System.Timeout.timeout terminates a threadWaitWrite using
asynchronous exceptions.

If you want to detect dead sockets somewhat reliably 
without a timeout then there is SO_KEEPALIVE combined
with polling SO_ERROR every few minutes.

- Taru Karttunen


More information about the Haskell-Cafe mailing list