tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Crowther <Peter.Crowt...@melandra.com>
Subject RE: CLOSE_WAIT and what to do about it
Date Tue, 14 Apr 2009 08:43:01 GMT
> From: André Warnier [mailto:aw@ice-sa.com]
>      public void close()
>          throws SomeException
>      {
>          putEndRequest();
>          flush();
>          socket = null;
>      }
> flush() being another function which reads the socket until there's
> nothing left to read, and throws away the result.
> "socket" is a property of the object created by this class, obtained
> somewhere else from a java.net.Socket object.
> Looking at that code above, it is obvious that "socket" is open, until
> it is set to null, without previously doing a socket.close().
> I don't know Java enough to know if this alone could cause that socket
> to be lingering until the GC, but I kind of suspect so.

Nice piece of detective work, André!  Yes, that code's broken - the socket's not referenced
but not closed, so it will stay open until a GC tidies it up.

$deity only knows what the original developer was thinking when they wrote that.

                - Peter

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message