[Haskell-cafe] sendfile leaking descriptors on Linux?
Brandon S. Allbery KF8NH
allbery at ece.cmu.edu
Fri Feb 26 06:26:54 EST 2010
On Feb 26, 2010, at 04:28 , Thomas Hartman wrote:
> me: Like mightybyte, I run my app in a shell loop that will just
> restart it after a crash. But every once in a while it won't restart
> because of the busy socket and I need to do a manual restart, killing
> multiple processes (usually 2).
>
> the error I get is:
>
> bind: resource busy (Address already in use)
This is on application restart? It's not out of file descriptors,
it's just the system keeping the socket around (netstat will show it
in TIME_WAIT, or possibly in a shutdown negotiation state such as
LAST_ACK, FIN_WAIT, etc. TCP lacks *reliable* socket shutdown
negotiation).
You want to configure the socket with SO_REUSEADDR before trying to
bind it (setSocketOption socket ReuseAddr 1).
As to the portable version of sendfile, it's because not all systems
offer a sendfile() system call. Linux and *BSD do, and can use the
native implementation; the portable version emulates sendfile() when
it doesn't exist, at the price of additional CPU usage/system load
(sendfile() having been created specifically to reduce system load in
the common case for web servers).
--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university KF8NH
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100226/cf51dd88/PGP.bin
More information about the Haskell-Cafe
mailing list