web-server port leak? was: [plt-scheme] Resource management in the web server

From: Noel Welsh (noelwelsh at yahoo.com)
Date: Fri Oct 13 06:55:49 EDT 2006

--- Jay McCarthy <jay.mccarthy at gmail.com> wrote:

> Here's the custodian hierarchy in the web server:
> 
> root custodian
> |--- server custodian
>        |--- connection custodian
>        |--- ...
>        |--- servlet custodian
>                    |--- instance custodian
>                    |--- ...
>        |--- ....

...

Thanks.  I've solved some of my problems with port leaks. 
However it appears the web server is leaking ports.  In my
setup the web-server sits behind Apache, which passes on
requests using mod_proxy.  Of the course of a day about 20
sockets accumulate.  Netstat shows the following sockets
opened by the web-server:

Proto Recv-Q Send-Q Local Address           Foreign Address
        State
tcp        1      0 localhost:8765          localhost:60715
        CLOSE_WAIT
tcp        1      0 localhost:8765          localhost:60713
        CLOSE_WAIT
tcp        1      0 localhost:8765          localhost:41991
        CLOSE_WAIT
tcp        1      0 localhost:8765          localhost:51210
        CLOSE_WAIT
tcp        1      0 localhost:8765          localhost:51211
        CLOSE_WAIT
tcp        1      0 localhost:8765          localhost:60946
        CLOSE_WAIT
tcp        1      0 localhost:8765          localhost:56080
        CLOSE_WAIT
tcp        1      0 localhost:8765          localhost:58976
        CLOSE_WAIT
etc.

The netstat man page says:

 CLOSE_WAIT
    The remote end has shut down, waiting for the socket to
close.

So it appears that the web-server is failing to shutdown
these sockets.  There is a OS level shutdown timer
associated with each socket, but it's value is 0, which I
think means the timer will never go off and so the socket
will never be closed by the OS.

Searching on the Interweb shows this a fairly common
problem, often associated with (HTTP/1.1) Keep-alive.  So
perhaps the web-server does not implement HTTP/1.1 and/or
Keep-alive fully?

The system is Linux running MzScheme 352.5.

Thanks,
Noel

Email: noelwelsh <at> yahoo <dot> com   noel <at> untyped <dot> com
AIM: noelhwelsh
Blogs: http://monospaced.blogspot.com/  http://www.untyped.com/untyping/

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


Posted on the users mailing list.