diff --git a/server/mpm/event/event.c b/server/mpm/event/event.c index 29d18a943ac..966691e3953 100644 --- a/server/mpm/event/event.c +++ b/server/mpm/event/event.c @@ -95,6 +95,7 @@ #include "http_vhost.h" #include "unixd.h" #include "apr_skiplist.h" +#include "ap_provider.h" #include "util_time.h" #include @@ -1323,6 +1324,13 @@ static apr_status_t event_resume_suspended (conn_rec *c) return OK; } +/* hack to allow a module to restart gracefully child */ +static void graceful_stop(void) +{ + signal_threads(ST_GRACEFUL); +} + + /* conns_this_child has gone to zero or below. See if the admin coded "MaxConnectionsPerChild 0", and keep going in that case. Doing it this way simplifies the hot path in worker_thread */ @@ -4270,6 +4278,8 @@ static void event_hooks(apr_pool_t * p) ap_hook_pre_connection(event_pre_connection, NULL, NULL, APR_HOOK_REALLY_FIRST); ap_hook_protocol_switch(event_protocol_switch, NULL, NULL, APR_HOOK_REALLY_FIRST); + + ap_register_provider(p, "gracefull" , event_get_name(), "0", &graceful_stop); } static const char *set_daemons_to_start(cmd_parms *cmd, void *dummy, diff --git a/server/mpm/prefork/prefork.c b/server/mpm/prefork/prefork.c index d9837725c9e..d5c025a5873 100644 --- a/server/mpm/prefork/prefork.c +++ b/server/mpm/prefork/prefork.c @@ -49,6 +49,8 @@ #include "apr_poll.h" #include "util_time.h" +#include "ap_provider.h" + #include #ifdef HAVE_TIME_H @@ -409,6 +411,13 @@ static void child_sigmask(sigset_t *new_mask, sigset_t *old_mask) } #endif +/* hack to allow a module to restart gracefully child */ +static void graceful_stop(void) +{ + clean_child_exit(0); +} + + static void child_main(int child_num_arg, int child_bucket) { #if APR_HAS_THREADS @@ -1510,6 +1519,8 @@ static void prefork_hooks(apr_pool_t *p) ap_hook_mpm(prefork_run, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_mpm_query(prefork_query, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_mpm_get_name(prefork_get_name, NULL, NULL, APR_HOOK_MIDDLE); + + ap_register_provider(p, "gracefull" , prefork_get_name(), "0", &graceful_stop); } static const char *set_daemons_to_start(cmd_parms *cmd, void *dummy, const char *arg) diff --git a/server/mpm/winnt/child.c b/server/mpm/winnt/child.c index 1ad8df0374b..2e87418432a 100644 --- a/server/mpm/winnt/child.c +++ b/server/mpm/winnt/child.c @@ -784,6 +784,12 @@ struct worker_info { int num; }; +/* hack to allow a module to restart gracefully child */ +void child_graceful_stop(void) +{ + SetEvent(max_requests_per_child_event); +} + /* * worker_thread() * Main entry point for the worker threads. Worker threads block in diff --git a/server/mpm/winnt/mpm_winnt.c b/server/mpm/winnt/mpm_winnt.c index cbc090fb662..5abf32946cd 100644 --- a/server/mpm/winnt/mpm_winnt.c +++ b/server/mpm/winnt/mpm_winnt.c @@ -1750,6 +1750,11 @@ static int winnt_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s ) return OK; /* Restart */ } +static void graceful_stop(void) +{ + child_graceful_stop(); +} + static void winnt_hooks(apr_pool_t *p) { /* Our open_logs hook function must run before the core's, or stderr @@ -1766,6 +1771,8 @@ static void winnt_hooks(apr_pool_t *p) ap_hook_mpm(winnt_run, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_mpm_query(winnt_query, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_mpm_get_name(winnt_get_name, NULL, NULL, APR_HOOK_MIDDLE); + + ap_register_provider(p, "gracefull" , winnt_get_name(), "0", &graceful_stop); } AP_DECLARE_MODULE(mpm_winnt) = { diff --git a/server/mpm/worker/worker.c b/server/mpm/worker/worker.c index aebbd0b6f4b..1329f14eaac 100644 --- a/server/mpm/worker/worker.c +++ b/server/mpm/worker/worker.c @@ -70,6 +70,8 @@ #include "unixd.h" #include "util_time.h" +#include "ap_provider.h" + #include #include /* for INT_MAX */ @@ -492,6 +494,12 @@ static void process_socket(apr_thread_t *thd, apr_pool_t *p, apr_socket_t *sock, } } +/* hack to allow a module to restart gracefully child */ +static void graceful_stop(void) +{ + signal_threads(ST_GRACEFUL); +} + /* requests_this_child has gone to zero or below. See if the admin coded "MaxConnectionsPerChild 0", and keep going in that case. Doing it this way simplifies the hot path in worker_thread */ @@ -2361,6 +2369,8 @@ static void worker_hooks(apr_pool_t *p) ap_hook_mpm(worker_run, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_mpm_query(worker_query, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_mpm_get_name(worker_get_name, NULL, NULL, APR_HOOK_MIDDLE); + + ap_register_provider(p, "gracefull" , worker_get_name(), "0", &graceful_stop); } static const char *set_daemons_to_start(cmd_parms *cmd, void *dummy,