]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Follow up to r1527220/r1588852:
authorJeff Trawick <trawick@apache.org>
Sat, 28 Jun 2014 15:01:11 +0000 (15:01 +0000)
committerJeff Trawick <trawick@apache.org>
Sat, 28 Jun 2014 15:01:11 +0000 (15:01 +0000)
Implement better error checking/reporting around notification of abrupt parent
process termination.

It is likely that something bad is happening here based on these
user reports:

https://www.apachelounge.com/viewtopic.php?p=27848
http://mail-archives.apache.org/mod_mbox/httpd-users/201406.mbox/%3CCAC%2BRZnuwLD%2BJnoy2TYO8oeAWt6bFLMa%3DEhfDf9hS3cuuGUHXAw%40mail.gmail.com%3E

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

docs/log-message-tags/next-number
server/mpm/winnt/child.c

index a54a3cb83cbbcac6c7110cd6eb4f6104c336a3d2..d76e014c090b1683645c8d114fc11e418d1e65f2 100644 (file)
@@ -1 +1 @@
-2643
+2645
index 7b7d213de5c3565ddec28012f704114696f6356c..dd3cf25345a3ecc1f658517f1e97c16fb9d458bd 100644 (file)
@@ -986,7 +986,15 @@ void child_main(apr_pool_t *pconf, DWORD parent_pid)
 
     if (parent_pid != my_pid) {
         child_events[2] = OpenProcess(SYNCHRONIZE, FALSE, parent_pid);
-        num_events = 3;
+        if (child_events[2] == NULL) {
+            num_events = 2;
+            ap_log_error(APLOG_MARK, APLOG_ERR, apr_get_os_error(), ap_server_conf, APLOGNO(02643)
+                         "Child: Failed to open handle to parent process %ld; "
+                         "will not react to abrupt parent termination", parent_pid);
+        }
+        else {
+            num_events = 3;
+        }
     }
     else {
         /* presumably -DONE_PROCESS */
@@ -1097,7 +1105,7 @@ void child_main(apr_pool_t *pconf, DWORD parent_pid)
         apr_sleep(apr_time_from_sec(1));
     }
 
-    /* Wait for one of three events:
+    /* Wait for one of these events:
      * exit_event:
      *    The exit_event is signaled by the parent process to notify
      *    the child that it is time to exit.
@@ -1106,6 +1114,8 @@ void child_main(apr_pool_t *pconf, DWORD parent_pid)
      *    This event is signaled by the worker threads to indicate that
      *    the process has handled MaxConnectionsPerChild connections.
      *
+     * parent process exiting
+     *
      * TIMEOUT:
      *    To do periodic maintenance on the server (check for thread exits,
      *    number of completion contexts, etc.)
@@ -1126,6 +1136,7 @@ void child_main(apr_pool_t *pconf, DWORD parent_pid)
         rv = WaitForMultipleObjects(num_events, (HANDLE *)child_events, FALSE, INFINITE);
         cld = rv - WAIT_OBJECT_0;
 #else
+        /* THIS IS THE EXPECTED BUILD VARIATION */
         rv = WaitForMultipleObjects(num_events, (HANDLE *)child_events, FALSE, 1000);
         cld = rv - WAIT_OBJECT_0;
         if (rv == WAIT_TIMEOUT) {
@@ -1138,6 +1149,17 @@ void child_main(apr_pool_t *pconf, DWORD parent_pid)
             ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_os_error(),
                          ap_server_conf, APLOGNO(00356)
                          "Child: WAIT_FAILED -- shutting down server");
+            /* check handle validity to identify a possible culprit */
+            for (i = 0; i < num_events; i++) {
+                DWORD out_flags;
+
+                if (0 == GetHandleInformation(child_events[i], &out_flags)) {
+                    ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_os_error(),
+                                 ap_server_conf, APLOGNO(02644)
+                                 "Child: Event handle #%d (%ld) is invalid",
+                                 i, child_events[i]);
+                }
+            }
             break;
         }
         else if (cld == 0) {