You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Arnab Ganguly <ag...@gmail.com> on 2008/09/03 09:44:09 UTC

Apache and CLOSE_WAIT state

Hi All,
My Apache module hangs when I do a lsof -i:listening port output gives lots
of CLOSE_WAIT.
Initially the state comes out as ESTABLISHED but as the CLOSE_WAIT grows my
server hangs.
What would be procedure in order to prevent this.
Apache Webserver version is 2.2.8 with MPM=worker and OS=Red-Hat Release 3.0
Any help would be very much appreciated.
Thanks and regards
Arnab

Re: Apache and CLOSE_WAIT state

Posted by Arnab Ganguly <ag...@gmail.com>.
Issue it that I am using Apache internal system calls like
[ap_setup_client_block,  ap_should_client_block , ap_get_client_block]
for client communication and the socket descriptors are not available
at this level, as per the apache doc ,when the Apache pool is
destroyed the sockets are also going to closed.But seems to be not
happening or may be I am doing something silly. How do I make sure the
sockets are being closed once the client disconnects.
Thanks in advance.
Arnab

On Wed, Sep 3, 2008 at 10:03 PM, Peter A. Friend <
octavian@corp.earthlink.net> wrote:

> Arnab Ganguly wrote:
>
>> Hi All,
>> My Apache module hangs when I do a lsof -i:listening port output gives
>> lots of CLOSE_WAIT.
>> Initially the state comes out as ESTABLISHED but as the CLOSE_WAIT grows
>> my server hangs.
>> What would be procedure in order to prevent this.
>> Apache Webserver version is 2.2.8 with MPM=worker and OS=Red-Hat Release
>> 3.0
>> Any help would be very much appreciated.
>> Thanks and regards
>> Arnab
>>
> How to fix it depends on what your module is attempting to do. It helps to
> understand what CLOSE_WAIT actually means, so grab your copy of Stevens...
>
> When a TCP socket receives a FIN (other end closed the socket) from it's
> peer the socket is then half closed. The FIN from the local socket to the
> peer won't be sent until the application issues the close(). Hence the name
> of the TCP state, CLOSE_WAIT, since TCP is waiting for the application to
> close its end of the connection.
>
> When CLOSE_WAIT piles up and doesn't go away it's usually an indication of
> a "descriptor leak" bug. Something is either preventing progress to occur in
> the HTTP session (we are stuck so never end up calling close), or some bug
> has been introduced that prevents the socket from being closed. There are a
> number of ways this can happen.
>
> Peter
>

Re: Apache and CLOSE_WAIT state

Posted by "Peter A. Friend" <oc...@corp.earthlink.net>.
Arnab Ganguly wrote:
> Hi All,
> My Apache module hangs when I do a lsof -i:listening port output gives 
> lots of CLOSE_WAIT.
> Initially the state comes out as ESTABLISHED but as the CLOSE_WAIT 
> grows my server hangs.
> What would be procedure in order to prevent this.
> Apache Webserver version is 2.2.8 with MPM=worker and OS=Red-Hat 
> Release 3.0
> Any help would be very much appreciated.
> Thanks and regards
> Arnab
How to fix it depends on what your module is attempting to do. It helps 
to understand what CLOSE_WAIT actually means, so grab your copy of 
Stevens...

When a TCP socket receives a FIN (other end closed the socket) from it's 
peer the socket is then half closed. The FIN from the local socket to 
the peer won't be sent until the application issues the close(). Hence 
the name of the TCP state, CLOSE_WAIT, since TCP is waiting for the 
application to close its end of the connection.

When CLOSE_WAIT piles up and doesn't go away it's usually an indication 
of a "descriptor leak" bug. Something is either preventing progress to 
occur in the HTTP session (we are stuck so never end up calling close), 
or some bug has been introduced that prevents the socket from being 
closed. There are a number of ways this can happen.

Peter

Re: Apache and CLOSE_WAIT state

Posted by Richard Hubbell <ri...@yahoo.com>.
--- On Wed, 9/3/08, Arnab Ganguly <ag...@gmail.com> wrote:

> From: Arnab Ganguly <ag...@gmail.com>
> Subject: Apache and CLOSE_WAIT state
> To: dev@httpd.apache.org
> Date: Wednesday, September 3, 2008, 12:44 AM
> Hi All,
> My Apache module hangs when I do a lsof -i:listening port
> output gives lots
> of CLOSE_WAIT.
> Initially the state comes out as ESTABLISHED but as the
> CLOSE_WAIT grows my
> server hangs.
> What would be procedure in order to prevent this.
> Apache Webserver version is 2.2.8 with MPM=worker and
> OS=Red-Hat Release 3.0
> Any help would be very much appreciated.
> Thanks and regards
> Arnab

There does seem to be close_wait issues. I've recently done
export CFLAGS=-DNO_LINGCLOSE before building so httpd won't use lingering_close.

There's also bug 36636 that may or may not be relevant to the issue.