]> granicus.if.org Git - apache/commitdiff
Win32: Prevent listening sockets from being inherited by
authorBill Stoddard <stoddard@apache.org>
Fri, 13 Jul 2001 18:46:15 +0000 (18:46 +0000)
committerBill Stoddard <stoddard@apache.org>
Fri, 13 Jul 2001 18:46:15 +0000 (18:46 +0000)
the Apache child process, CGI scripts, rotatelog process
etc.  If the Apache child process segfaults, any processes
that the child started are not reaped. Prior to this fix,
these processes inherited the listening sockets which sometimes
prevented the restarted Apache child process from accepting
connections (ie, the server would hang).

The Sleep(1000) is a bit of a hack but it is sufficient I believe. All
that is really necessary is for the parent to give up its quantum and
allow the child to run. I could not get WaitForInputIdle to work properly.
Will investigate alternative solutions later.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@89547 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
server/mpm/winnt/mpm_winnt.c

diff --git a/CHANGES b/CHANGES
index 425c7341a8ba62184f6d02ba0cc66c7a02ea6d60..f2fe09c35a79ec02531323ad00a24cbf6d792030 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,14 @@
 Changes with Apache 2.0.21-dev
+
+  *) Win32: Prevent listening sockets from being inherited by
+     the Apache child process, CGI scripts, rotatelog process
+     etc.  If the Apache child process segfaults, any processes 
+     that the child started are not reaped. Prior to this fix,
+     these processes inherited the listening sockets which sometimes
+     prevented the restarted Apache child process from accepting
+     connections (ie, the server would hang). 
+     [Bill Stoddard]
+
   *) Provide vhost and request strings when ExtendedStatus is on.
      [Greg Ames]
 
index 19759df57ea16a8a6f4e9238e608b317593e3631..e4b88c5748808e24e7103ac1769ae6f877997ab3 100644 (file)
@@ -75,7 +75,6 @@
 #include "mpm_common.h"
 #include "scoreboard.h"
 
-
 typedef HANDLE thread;
 #ifdef CONTAINING_RECORD
 #undef CONTAINING_RECORD
@@ -1323,6 +1322,14 @@ static int create_process(apr_pool_t *p, HANDLE *handles, HANDLE *events, int *p
     ResumeThread(pi.hThread);
     CloseHandle(pi.hThread);
 
+    /* Important:
+     * Give the child process a chance to run before dup'ing the sockets.
+     * We have already set the listening sockets noninheritable, but if 
+     * WSADuplicateSocket runs before the child process initializes
+     * the listeners will be inherited anyway.
+     */
+    Sleep(1000);
+
     /* Run the chain of open sockets. For each socket, duplicate it 
      * for the target process then send the WSAPROTOCOL_INFO 
      * (returned by dup socket) to the child.