httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@ai.mit.edu (Robert S. Thau)
Subject Re: UnixWare (net gurus please comment)
Date Wed, 26 Jun 1996 16:37:04 GMT
  One thing that the netstat output showed me from these UnixWare
  sites was a higher than normal number of FIN_WAIT_2 connections.
  I raised this question awhile back but did not see any comments.

  Could some socket guru explain what this might indicate?
  Is this a side effect of SO_LINGER being used?

I hadn't made the connection before, but now that you mention it,
it might be.  What SO_LINGER does is to keep the socket from finally
being deallocated until the client has explicitly acknowledged the
last data packets that were sent.  This is *supposed* to have a 
timeout, so the things don't hang around forever, but on many 
Unices with buggy TCP stacks, the timeout is inoperative, and the
sockets *will* hang around forever if the client fails to send the
final ack.  

If this is the problem, one *possible* (i.e., untried and may not
work) solution is to simulate the desired effect of SO_LINGER "by
hand", by doing a 'shutdown(..., 1)' to signal the client that no
more data is coming, and waiting for the socket to show readable
in a select(), which will generally happen when the client has
closed *its* end of the socket (what you can read is then EOF).

There is one subtlety that comes in with keep-alives --- if the
client decides to send a request just as we are closing the socket,
that request and our FIN can cross in the network.  To deal with that
correctly, you have to be prepared for data to come in on the half-
closed socket, and to silently discard it.

rst

Mime
View raw message