httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Stoddard" <>
Subject Re: nasty bug in Apache for Windows (1.3 & 2.)
Date Fri, 13 Jul 2001 19:44:24 GMT
> > > > The problem is that the processes started by the child are inheriting the
sockets from the
> > child. I
> > > > wasn't clear about that.
> > > >
> > > > The parent needs to manage the listen sockets to enable graceful restarts
to work.  Having
> > > > parent own the listeners allows us to not destroy the listen queue (and
anything on it)
across a
> > > > graceful restart.  The code to prevent inheriting the socket is quite
simple, it was just
> > behaving
> > > > strangely (see below).
> > >
> > > I have a patch on my computer that closes the sockets when children create
> > > child processes.  I haven't committed it because I haven't fully tested it
> > > yet.  I'll try to finish it up and commit it tonight.  This patch should
> > > fix a big part of this part of the problem.
> > >
> >
> > I suspect your patch is specific to Unix.  I already have the fix for the Windows
> It shouldn't be.  There is a bug in the Bug DB that says that child
> processes children are not closing the socket.  This is happening on ALL
> platforms.  The solution should be to add the correct cleanups so that the
> socket is closed whenever the child calls apr_create_process.

The child process under Windows can inherit socket descriptors, but it has no way of knowing
value of the inherited descriptors. (remember, Windows does not fork).  On Windows, you have
explicitly tell the child (via some sort of IPC) about the values of the inherited descriptors.

So this problem can be fixed in two ways on Windows...
Soln 1 (the wrong solution): Allow the child to inherit the sockets, then have the parent
communicate the values to the child (via a pipe for instance) so the child can then close
inherited sockets.

Soln2 (the right way):  Use DuplicateHandle to set the listeners noninheritable in the parent
after they are opened.  This is the fix I checked in this AM.

Note, I use WSADuplicateSocket and a pipe to -explicitly- send the listeners to the child
than have the child inherit the sockets.  This is the preferred way to share sockets among
using Winsock2.  WSADuplicateSocket is more reliable (and flexible) than implicitly sharing
via inheritance.


View raw message