
Thanks, I altered my top level request handler as follows
mysmartserver conf h stateProxy = do
socket <- bindPort conf
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@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH