]> granicus.if.org Git - apache/commitdiff
mpm_winnt: make AP_MPMQ_GENERATION available in the child process as soon
authorYann Ylavic <ylavic@apache.org>
Tue, 15 Sep 2015 11:40:53 +0000 (11:40 +0000)
committerYann Ylavic <ylavic@apache.org>
Tue, 15 Sep 2015 11:40:53 +0000 (11:40 +0000)
as possible, so that hooks/modules can query it at config stage.
This is (e.g.) needed by r1702501 for PR 58024.

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

server/mpm/winnt/mpm_winnt.c

index 2e7295b0e58637c571ad0dd7d1e8842adf9466af..2d75a524da94792bf98d296ffb847f91e849aa92 100644 (file)
@@ -359,6 +359,13 @@ static int send_handles_to_child(apr_pool_t *p,
     HANDLE os_start;
     HANDLE hScore;
 
+    if ((rv = apr_file_write_full(child_in, &my_generation,
+                                  sizeof(my_generation), NULL))
+            != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_CRIT, rv, ap_server_conf, APLOGNO(02964)
+                     "Parent: Unable to send its generation to the child");
+        return -1;
+    }
     if (!DuplicateHandle(hCurrentProcess, child_ready_event, hProcess, &hDup,
         EVENT_MODIFY_STATE | SYNCHRONIZE, FALSE, 0)) {
         ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_os_error(), ap_server_conf, APLOGNO(00392)
@@ -1036,6 +1043,7 @@ static void winnt_rewrite_args(process_rec *process)
     {
         HANDLE filehand;
         HANDLE hproc = GetCurrentProcess();
+        DWORD BytesRead;
 
         /* This is the child */
         my_pid = GetCurrentProcessId();
@@ -1073,6 +1081,16 @@ static void winnt_rewrite_args(process_rec *process)
          * already
          */
 
+        /* Read this child's generation number as soon as now,
+         * so that further hooks can query it.
+         */
+        if (!ReadFile(pipe, &my_generation, sizeof(my_generation),
+                      &BytesRead, (LPOVERLAPPED) NULL)
+                || (BytesRead != sizeof(my_generation))) {
+            ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_os_error(), NULL, APLOGNO(02965)
+                         "Child: Unable to retrieve my generation from the parent");
+            exit(APEXIT_CHILDINIT);
+        }
 
         /* The parent is responsible for providing the
          * COMPLETE ARGUMENTS REQUIRED to the child.
@@ -1664,8 +1682,6 @@ static void winnt_child_init(apr_pool_t *pchild, struct server_rec *s)
 
         /* Done reading from the parent, close that channel */
         CloseHandle(pipe);
-
-        my_generation = ap_scoreboard_image->global->running_generation;
     }
     else {
         /* Single process mode - this lock doesn't even need to exist */