> > > > 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
the
> > > > 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 
>MPM.
>
> 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 the
value of the inherited descriptors. (remember, Windows does not fork).  On Windows, 
you have to
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 the
inherited sockets.

Soln2 (the right way):  Use DuplicateHandle to set the listeners noninheritable in the 
parent right
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 rather
than have the child inherit the sockets.  This is the preferred way to share sockets 
among processes
using Winsock2.  WSADuplicateSocket is more reliable (and flexible) than implicitly 
sharing sockets
via inheritance.

Bill

Reply via email to