From: Yann Ylavic Date: Wed, 29 Aug 2018 12:27:31 +0000 (+0000) Subject: MPMs: early initialize scoreboard's child generation number. X-Git-Tag: 2.5.0-alpha2-ci-test-only~2363 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=972ad6c66d7f67c847ada45c050e031a88774489;p=thirdparty%2Fapache%2Fhttpd.git MPMs: early initialize scoreboard's child generation number. 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 --- diff --git a/server/mpm/event/event.c b/server/mpm/event/event.c index 47053a7d7b5..e491927103e 100644 --- a/server/mpm/event/event.c +++ b/server/mpm/event/event.c @@ -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) diff --git a/server/mpm/motorz/motorz.c b/server/mpm/motorz/motorz.c index f3a543e7985..fe31e147a92 100644 --- a/server/mpm/motorz/motorz.c +++ b/server/mpm/motorz/motorz.c @@ -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 */ diff --git a/server/mpm/netware/mpm_netware.c b/server/mpm/netware/mpm_netware.c index 615956c34ab..a2f28626428 100644 --- a/server/mpm/netware/mpm_netware.c +++ b/server/mpm/netware/mpm_netware.c @@ -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, diff --git a/server/mpm/prefork/prefork.c b/server/mpm/prefork/prefork.c index 32555295fa2..78e64ab64da 100644 --- a/server/mpm/prefork/prefork.c +++ b/server/mpm/prefork/prefork.c @@ -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 */ diff --git a/server/mpm/winnt/mpm_winnt.c b/server/mpm/winnt/mpm_winnt.c index 0ca2ad33625..6ef00fa5fc9 100644 --- a/server/mpm/winnt/mpm_winnt.c +++ b/server/mpm/winnt/mpm_winnt.c @@ -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); diff --git a/server/mpm/worker/worker.c b/server/mpm/worker/worker.c index 6fad701beee..26fc324262f 100644 --- a/server/mpm/worker/worker.c +++ b/server/mpm/worker/worker.c @@ -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)