From 243c5fad0a8da9a1008681ac60f5b981de6c18d6 Mon Sep 17 00:00:00 2001 From: Yann Ylavic Date: Tue, 24 Aug 2021 22:22:40 +0000 Subject: mpm_{event,worker,prefork}: late stop of children processes on restart. Change how the main process handles restarts, from: 0. 1. stop old generation of children processes (graceful or not) 2. reload new configuration 3. start new generation of children processes to: 0. 1. reload new configuration 2. stop old generation of children processes (graceful or not) 3. start new generation of children processes The delay between stop and start is now very short and does not depend on the reload time (which can be quite long with many vhosts and/or complex setups with regexps or whatever third party components to compile). Also, while reloading, the old generation of children processes keeps accepting and handling incoming connections until the new generation is up to take over. * os/unix/unixd.c (sig_term, sig_restart): Set AP_MPMQ_STOPPING only once. * server/listen.c (ap_duplicate_listeners): Use ap_log_error() the main server instead of ap_log_perror(). * server/mpm/{event,worker,prefork}/{event,worker,prefork}.c ({event,worker,prefork}_retained_data): Save the generation pool pointer (gen_pool) and all the buckets here, they won't be cleared before the reload like pconf so they need a persitent storage accross restarts (i.e. retained->gen_pool). * server/mpm/{event,worker,prefork}/{event,worker,prefork}.c (perform_idle_server_maintenance, child_main, make_child): Change usage of all_buckets (previously with global/static scope) to the new retained->buckets array. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1892587 13f79535-47bb-0310-9956-ffa450edef68 --- os/unix/unixd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'os') diff --git a/os/unix/unixd.c b/os/unix/unixd.c index 3b0e695727..eed76f683b 100644 --- a/os/unix/unixd.c +++ b/os/unix/unixd.c @@ -469,7 +469,6 @@ static void sig_term(int sig) /* Main process (ap_pglobal) is dying */ return; } - retained_data->mpm_state = AP_MPMQ_STOPPING; if (retained_data->shutdown_pending && (retained_data->is_ungraceful || sig == AP_SIG_GRACEFUL_STOP)) { @@ -477,6 +476,7 @@ static void sig_term(int sig) return; } + retained_data->mpm_state = AP_MPMQ_STOPPING; retained_data->shutdown_pending = 1; if (sig != AP_SIG_GRACEFUL_STOP) { retained_data->is_ungraceful = 1; @@ -489,7 +489,6 @@ static void sig_restart(int sig) /* Main process (ap_pglobal) is dying */ return; } - retained_data->mpm_state = AP_MPMQ_STOPPING; if (retained_data->restart_pending && (retained_data->is_ungraceful || sig == AP_SIG_GRACEFUL)) { @@ -497,6 +496,7 @@ static void sig_restart(int sig) return; } + retained_data->mpm_state = AP_MPMQ_STOPPING; retained_data->restart_pending = 1; if (sig != AP_SIG_GRACEFUL) { retained_data->is_ungraceful = 1; -- cgit v1.2.1