You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Ruediger Pluem <rp...@apache.org> on 2009/03/30 21:00:04 UTC

Behaviour of SO_LINGER

 Does anybody know if the below comment from connection.c is still true?

 * In an ideal world, this function would be accomplished by simply
 * setting the socket option SO_LINGER and handling it within the
 * server's TCP stack while the process continues on to the next request.
 * Unfortunately, it seems that most (if not all) operating systems
 * block the server process on close() when SO_LINGER is used.
 * For those that don't, see USE_SO_LINGER below.  For the rest,
 * we have created a home-brew lingering_close.

According to the code no OS at all does it correct as USE_SO_LINGER
is not used in the code below.

Regards

RĂ¼diger

Re: Behaviour of SO_LINGER

Posted by Jeff Trawick <tr...@gmail.com>.
On Mon, Mar 30, 2009 at 3:00 PM, Ruediger Pluem <rp...@apache.org> wrote:

>  Does anybody know if the below comment from connection.c is still true?
>
>  * In an ideal world, this function would be accomplished by simply
>  * setting the socket option SO_LINGER and handling it within the
>  * server's TCP stack while the process continues on to the next request.
>  * Unfortunately, it seems that most (if not all) operating systems
>  * block the server process on close() when SO_LINGER is used.
>  * For those that don't, see USE_SO_LINGER below.  For the rest,
>  * we have created a home-brew lingering_close.


(from 1.3)

The premise seems questionable.  The part about "block the server process on
close() when SO_LINGER is used" ignores the fact that 1.3 on Unix had
blocking sockets (timeouts were handled by the parent sending SIGALRM), so
close with SO_LINGER was supposed to block. And I don't see code in 1.3 to
set non-blocking when USE_SO_LINGER is defined.

Section 7.5 of Stevens' UNPv1 (2e) covers SO_LINGER and the sort of logic we
have in its place, but unfortunately doesn't describe SO_LINGER behavior for
non-blocking sockets.