From: "Bill Stoddard" <[EMAIL PROTECTED]>
Sent: Thursday, July 12, 2001 1:18 PM
> This is definitely in 2.0 and I believe it is in 1.3 as well.
>
> If the Apache child process segfaults while any other process it started is running
>(CGI,
> rotatelogs, etc,), there is a chance that the server will stop serving pages, even
>after a complete
> shutdown and restart of Apache. The problem is twofold...
>
> 1. When an Apache (for Windows) child process segfaults, any processes it started
>are stranded and
> not cleaned up. The Win32 API does not provide any facilities to tell the system to
>kill off any
> child processes when the parent dies abnormally. This is the least serious part of
>the problem.
True ... win32 folks have expected that for some time. It deserves to be fixed, but
isn't as critical.
> 2. This is the nasty part... Due to a bug in the Windows part of Apache, child
>processes are
> inheriting open socket descriptors. When the Apache child process segfaults, its
>child processes
> have copies of the open socket descriptors which can prevent the new Apache process
>from accepting
> connections.. This could explain some long standing bug reports in the bugdb.
Why, specifically, do we have the parent keep the sockets open? Can we simply open
the parent socket
(to test that it is available, and try it exclusively, since we don't do that
correctly now anyways),
then close it, and let the child threads open their own (non-inhertable) sockets,
themselves?
Does this really cost us that much?
> Solutions...
> Sockets are created as inheritable by default. We need to use DuplicateHandle to
>create
> noninheritable handles of the listeners. This is a bit tricker than it first
>appears and I spent
> the better part of this AM getting this to work. There are some funky race
>conditions between
> CreateProcess() (to create the Apache child process) and WSADuplicateSocket() that
>will, if not
> handled properly, undo any effort to make the listeners noninheritable.
Not sure how there is a race here... they are still opened (in the parent)
inheritable), simply dup as
a non-inheritable and close the inherited socket in the child, no?
> I have no thoughts on how to cleanly solve problem 1. Would be nice if there were
>some system calls
> to bind the two processes together in a parent/child relationship.
Oh, yeah... took them till NT 5 to figure that out themselves :-/
> Workarounds:
> Reboot :-( or if you are familier enough with the processes Apache starts on your
>system, shutdown
> Apache then search and destroy the leftover processes (rotatelogs, CGI, etc.) that
>Apache should
> have cleaned up. If you do a netstat -an and still find a listener on your webserver
>port, you
> missed something.
Thanks for all the details, look forward to seeing the code