You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Ed Korthof <ed...@apache.org> on 2000/07/06 12:11:10 UTC

lingering_close / SO_LINGER

Hi --

While looking into providing lingering_close (in apache 1.3.x) or
SO_LINGER to Apache JServ (apparently some features break on BS2000
otherwise), I wound up looking through the source to APR ... I from what I
can see, it seems to use only SO_LINGER -- and only if ap_setsocketopt is
called with that value, which doesn't ever seem to happen, since
APR_SO_LINGER is never mentioned outside apr.

My questions are ...

1) is there an equivalent to lingering_close, in APR, which i missed?
	(quite possible, i didn't look too closely.)

2) is SO_LINGER safe everywhere, or is something like lingering_close (in
	Apache 1.3.x) still needed?  based on what i've read recently, i'm
	guessing the latter...

3) is SO_LINGER somehow being enabled (on platforms where it's safe)?  if
	so, i'm curious as to how.

This won't matter much until Apache 2.0 is in use in production
environments, but afaik it will then.

...

Anyway, in 1.3.x, lingering_close/SO_LINGER aren't exposed.  Should they
be?  I'm not sure if this falls under the list of operations still allowed
for 1.3.x (it's not clear it's a bug fix), but -- assuming SO_LINGER isn't
safe everywhere -- it might be nice to provide an API to these.  I'd be
happy to do that (basically by moving some functions from http_main.c to
buff.c and making the available elsewhere).

Apache JServ has gotten by well enough so far without SO_LINGER, so I'm
guessing this is just a quirk of BS2000 -- I don't think it'll be a big
deal if we don't get lingering_close/SO_LINGER right now.  OTOH, it seems
like this might be useful for mod_proxy (which is making http connections
to remote servers) and possibly other modules ...

thanks in advance --

Ed


Re: lingering_close / SO_LINGER

Posted by Bill Stoddard <st...@raleigh.ibm.com>.
> On Thu, 6 Jul 2000, Bill Stoddard wrote:
>
> > > 1) is there an equivalent to lingering_close, in APR, which i missed?
> > > (quite possible, i didn't look too closely.)
> >
> > No. ap_lingering_close() is still an Apache function that resides in
> > http_connection.c.
>
> ah, thanks for pointing this out.  so -- why is this in apache instead of
> apr?  perhaps it's not useful for all servers, but it seems that the logic
> for this out to occur in the same place as that used SO_LINGER -- APR is
> supposed to be the place for platform-specific code, right?

It could go into APR and probably should.


>
> > > 2) is SO_LINGER safe everywhere, or is something like lingering_close (in
> > > Apache 1.3.x) still needed?  based on what i've read recently, i'm
> > > guessing the latter...
> >
> > SO_LINGER is not implemented correctly on most systems (that is the concensus, I
cannot
> > say this with certainty from personal experience. SO_LINGER does seem to work
correctly on
> > Windows though). ap_lingering_close() does an explicit shutdown of the connection in
both
> > directions, then waits a while (using select) for any further packets received from
the
> > client (which are dumped into the bit bucket), then closes the socket.  If you have
any
> > doubt about your systems implementation of SO_LINGER, use lingering close. The worst
that
> > can happen is you take a slight performance hit.
>
> according to some documents written about when Apache 1.2 was being
> developed, some systems will panic (or react badly) if you do a
> half-shutdown as lingering_close does.  (thus the NO_LINGERING_CLOSE
> compiler define.)  i dunno if there are any systems for which this is
> currently an issue, though.

Speak of the devil... I am having a problem similar to this now in Apache 2.0 for Windows.
shutdown fails, then Apache seg faults doing a closesocket. Hummm...




Re: lingering_close / SO_LINGER

Posted by Ed Korthof <ed...@apache.org>.
On Thu, 6 Jul 2000, Bill Stoddard wrote:

> > 1) is there an equivalent to lingering_close, in APR, which i missed?
> > (quite possible, i didn't look too closely.)
> 
> No. ap_lingering_close() is still an Apache function that resides in
> http_connection.c.

ah, thanks for pointing this out.  so -- why is this in apache instead of
apr?  perhaps it's not useful for all servers, but it seems that the logic
for this out to occur in the same place as that used SO_LINGER -- APR is
supposed to be the place for platform-specific code, right?

> > 2) is SO_LINGER safe everywhere, or is something like lingering_close (in
> > Apache 1.3.x) still needed?  based on what i've read recently, i'm
> > guessing the latter...
> 
> SO_LINGER is not implemented correctly on most systems (that is the concensus, I cannot
> say this with certainty from personal experience. SO_LINGER does seem to work correctly on
> Windows though). ap_lingering_close() does an explicit shutdown of the connection in both
> directions, then waits a while (using select) for any further packets received from the
> client (which are dumped into the bit bucket), then closes the socket.  If you have any
> doubt about your systems implementation of SO_LINGER, use lingering close. The worst that
> can happen is you take a slight performance hit.

according to some documents written about when Apache 1.2 was being
developed, some systems will panic (or react badly) if you do a
half-shutdown as lingering_close does.  (thus the NO_LINGERING_CLOSE
compiler define.)  i dunno if there are any systems for which this is
currently an issue, though.

> > 3) is SO_LINGER somehow being enabled (on platforms where it's safe)?  if
> > so, i'm curious as to how.
> 
> setsockopt() (or ap_setsockopt)
> 
> So yes, lingering close of connections is necessary for all
> webservers, including Apache 2.0. The only question is how you
> implement it, explicitly via ap_lingering_close or using
> setsockopt(SO_LINGER).

looking at http_connection.c, i see where setsockopt is called -- but i
can't find any place where ap_setsocketopt is called.  it seems like that
ought to be fixed -- ap_setsocketopt should be used, right?  i can post a
patch to this, but i'm not too familiar with the code / possible side
effects.

thanks --

ed


Re: lingering_close / SO_LINGER

Posted by Bill Stoddard <st...@raleigh.ibm.com>.
> Hi --
>
> While looking into providing lingering_close (in apache 1.3.x) or
> SO_LINGER to Apache JServ (apparently some features break on BS2000
> otherwise), I wound up looking through the source to APR ... I from what I
> can see, it seems to use only SO_LINGER -- and only if ap_setsocketopt is
> called with that value, which doesn't ever seem to happen, since
> APR_SO_LINGER is never mentioned outside apr.
>
> My questions are ...
>
> 1) is there an equivalent to lingering_close, in APR, which i missed?
> (quite possible, i didn't look too closely.)

No. ap_lingering_close() is still an Apache function that resides in http_connection.c.

>
> 2) is SO_LINGER safe everywhere, or is something like lingering_close (in
> Apache 1.3.x) still needed?  based on what i've read recently, i'm
> guessing the latter...

SO_LINGER is not implemented correctly on most systems (that is the concensus, I cannot
say this with certainty from personal experience. SO_LINGER does seem to work correctly on
Windows though). ap_lingering_close() does an explicit shutdown of the connection in both
directions, then waits a while (using select) for any further packets received from the
client (which are dumped into the bit bucket), then closes the socket.  If you have any
doubt about your systems implementation of SO_LINGER, use lingering close. The worst that
can happen is you take a slight performance hit.

>
> 3) is SO_LINGER somehow being enabled (on platforms where it's safe)?  if
> so, i'm curious as to how.

setsockopt() (or ap_setsockopt)

So yes, lingering close of connections is necessary for all webservers, including Apache
2.0. The only question is how you implement it, explicitly via ap_lingering_close or using
setsockopt(SO_LINGER).

Bill



Re: lingering_close / SO_LINGER

Posted by Jeff Trawick <tr...@ibm.net>.
> Date: Thu, 6 Jul 2000 03:11:10 -0700 (PDT)
> From: Ed Korthof <ed...@apache.org>

> 1) is there an equivalent to lingering_close, in APR, which i missed?
> 	(quite possible, i didn't look too closely.)

no; see ap_lingering_close() in http_connection.c

> 
> 2) is SO_LINGER safe everywhere, or is something like lingering_close (in
> 	Apache 1.3.x) still needed?  based on what i've read recently, i'm
> 	guessing the latter...

just like 1.3: SO_LINGER isn't safe everywhere; something like
lingering_close() is still needed


-- 
Jeff Trawick | trawick@ibm.net | PGP public key at web site:
     http://www.geocities.com/SiliconValley/Park/9289/
          Born in Roswell... married an alien...

Re: bugs.apache.org

Posted by Ed Korthof <ed...@apache.org>.
On Thu, 6 Jul 2000 rbb@covalent.net wrote:

> Bugs.apache.org is currently down with an Internal Server Error.  Does
> anybody have enough access to figure out and fix it?

Well, I can tell you what's wrong -- the new system has /usr/bin/perl
(without a symlink at /usr/local/bin/perl), and the CGI in question uses
the latter path.  But I can't fix it -- if someone has access to the bugz
user, they could edit the cgi.  Otherwise, it should be fixed within a
couple of hours.

thanks --

Ed


bugs.apache.org

Posted by rb...@covalent.net.

Bugs.apache.org is currently down with an Internal Server Error.  Does
anybody have enough access to figure out and fix it?

Ryan
_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------