httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Slemko <ma...@znep.com>
Subject Re: [PATCH] lingering_close cleanups
Date Fri, 24 Jan 1997 01:34:52 GMT
On Thu, 23 Jan 1997, Roy T. Fielding wrote:

> > One thing that needs to be added before the final close() in
> > lingering_close() is something like:
> > 
> > 	#ifdef NEED_SHUTDOWN
> > 	/* some broken SVR4 systems flush data queued for sending when
> > 	 * the socket is destroyed.  Doing a shutdown() first should
> > 	 * prevent that.
> > 	 */
> > 	shutdown(sd, 2);
> > 	#endif /* NEED_SHUTDOWN */
> 
> I don't understand why we would want to prevent that.  Does it get
> stuck in a bad state or something?  I think what you are referring
> to only happens when SO_LINGER is set (which is why we don't set it).
> Or am I missing something?

Some SVR4 (SVR4 doesn't actually really define anything much in the way of
an exact OS, but it is the closest I can get) systems have a bug.  If you
have data queued to send and do a close() on the socket, the kernel
destroys everything associated with the socket including the queued data. 
"flush" is probably a bad word, since it can be associated with normal
flushing, ie. sending the data.  This behavior is broken, broken, broken. 

It is why the archives say SO_LINGER was tried and lingering_close was
added (the code was offered by RST in a response to this problem, but most
likely after discussion of it and why it is needed for other reasons
privately).  If you just do a close() on the broken systems, the client
gets truncated responses.  A supposed (as per the sockets FAQ) workaround
is to do a shutdown() first; the shutdown is supposed to properly flush
the queue without destroying data.  

If you check the list archives from somewhere in the first three or four
months of '96, one of the first messages with SO_LINGER in it should be
the patch someone with such a broken system submitted which started the
SO_LINGER thing.  The problem is less likely to happen in
lingering_close() because it delays for longer before doing a close(), but
to fix it we need a shutdown() on the broken systems.



Mime
View raw message