]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
MPMs: early initialize scoreboard's child generation number.
authorYann Ylavic <ylavic@apache.org>
Wed, 29 Aug 2018 12:27:31 +0000 (12:27 +0000)
committerYann Ylavic <ylavic@apache.org>
Wed, 29 Aug 2018 12:27:31 +0000 (12:27 +0000)
Since [mpm]_note_child_killed uses the scoreboard's generation number for
child_status hook (MPM_CHILD_EXITED), we must initialize it early (i.e. in
[mpm]_note_child_started where MPM_CHILD_STARTED is set) to avoid race
conditions on restart (e.g. storm/loop of restarts) leading to AH00546.

PR 62658.

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

server/mpm/event/event.c
server/mpm/motorz/motorz.c
server/mpm/netware/mpm_netware.c
server/mpm/prefork/prefork.c
server/mpm/winnt/mpm_winnt.c
server/mpm/worker/worker.c

index 47053a7d7b5676a454cb71486ee08dac6d00eff9..e491927103e59f73a04f9467f106707955b90a93 100644 (file)
@@ -748,10 +748,10 @@ static void event_note_child_killed(int childnum, pid_t pid, ap_generation_t gen
 
 static void event_note_child_started(int slot, pid_t pid)
 {
+    ap_generation_t gen = retained->mpm->my_generation;
     ap_scoreboard_image->parent[slot].pid = pid;
-    ap_run_child_status(ap_server_conf,
-                        ap_scoreboard_image->parent[slot].pid,
-                        retained->mpm->my_generation, slot, MPM_CHILD_STARTED);
+    ap_scoreboard_image->parent[slot].generation = gen;
+    ap_run_child_status(ap_server_conf, pid, gen, slot, MPM_CHILD_STARTED);
 }
 
 static const char *event_get_name(void)
index f3a543e79850fb09696ddbe8599267e0bc43b368..fe31e147a92150181963b0e9b33a1455383c0a94 100644 (file)
@@ -573,10 +573,10 @@ static void motorz_note_child_killed(int childnum, pid_t pid,
 
 static void motorz_note_child_started(motorz_core_t *mz, int slot, pid_t pid)
 {
+    ap_generation_t gen = mz->mpm->my_generation;
     ap_scoreboard_image->parent[slot].pid = pid;
-    ap_run_child_status(ap_server_conf,
-                        ap_scoreboard_image->parent[slot].pid,
-                        mz->mpm->my_generation, slot, MPM_CHILD_STARTED);
+    ap_scoreboard_image->parent[slot].generation = gen;
+    ap_run_child_status(ap_server_conf, pid, gen, slot, MPM_CHILD_STARTED);
 }
 
 /* a clean exit from a child with proper cleanup */
index 615956c34ab5c37877c4b8ca8ebb051245030a76..a2f2862642806853c9a1fde229bc38af3972809f 100644 (file)
@@ -886,6 +886,7 @@ static int netware_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
 
     /* Only set slot 0 since that is all NetWare will ever have. */
     ap_scoreboard_image->parent[0].pid = getpid();
+    ap_scoreboard_image->parent[0].generation = ap_my_generation;
     ap_run_child_status(ap_server_conf,
                         ap_scoreboard_image->parent[0].pid,
                         ap_my_generation,
index 32555295fa2c184aecf46950a78047631bedde08..78e64ab64daf2887adf6d0dcee7f215b1328c037 100644 (file)
@@ -209,10 +209,10 @@ static void prefork_note_child_killed(int childnum, pid_t pid,
 
 static void prefork_note_child_started(int slot, pid_t pid)
 {
+    ap_generation_t gen = retained->mpm->my_generation;
     ap_scoreboard_image->parent[slot].pid = pid;
-    ap_run_child_status(ap_server_conf,
-                        ap_scoreboard_image->parent[slot].pid,
-                        retained->mpm->my_generation, slot, MPM_CHILD_STARTED);
+    ap_scoreboard_image->parent[slot].generation = gen;
+    ap_run_child_status(ap_server_conf, pid, gen, slot, MPM_CHILD_STARTED);
 }
 
 /* a clean exit from a child with proper cleanup */
index 0ca2ad3362543cc401d3b6bee1b7038cffc7b785..6ef00fa5fc9de7092666d4dd7edc439773a401c2 100644 (file)
@@ -139,6 +139,7 @@ AP_INIT_TAKE1("ThreadLimit", set_thread_limit, NULL, RSRC_CONF,
 static void winnt_note_child_started(int slot, pid_t pid)
 {
     ap_scoreboard_image->parent[slot].pid = pid;
+    ap_scoreboard_image->parent[slot].generation = my_generation;
     ap_run_child_status(ap_server_conf,
                         ap_scoreboard_image->parent[slot].pid,
                         my_generation, slot, MPM_CHILD_STARTED);
index 6fad701beeeaa290ebe497532bc94b953fb2a055..26fc324262f4f56737dd580e2ebb25b84b3bb8b6 100644 (file)
@@ -396,10 +396,10 @@ static void worker_note_child_killed(int childnum, pid_t pid, ap_generation_t ge
 
 static void worker_note_child_started(int slot, pid_t pid)
 {
+    ap_generation_t gen = retained->mpm->my_generation;
     ap_scoreboard_image->parent[slot].pid = pid;
-    ap_run_child_status(ap_server_conf,
-                        ap_scoreboard_image->parent[slot].pid,
-                        retained->mpm->my_generation, slot, MPM_CHILD_STARTED);
+    ap_scoreboard_image->parent[slot].generation = gen;
+    ap_run_child_status(ap_server_conf, pid, gen, slot, MPM_CHILD_STARTED);
 }
 
 static void worker_note_child_lost_slot(int slot, pid_t newpid)