diff options
author | Jeff Trawick <trawick@apache.org> | 2011-03-30 23:32:10 +0200 |
---|---|---|
committer | Jeff Trawick <trawick@apache.org> | 2011-03-30 23:32:10 +0200 |
commit | 3c0476fe509b3d8bc4839a266f5de9138c73acda (patch) | |
tree | 02de618be2053b7c24a13d18b136540e3bd94282 /server | |
parent | the mpm-note-child-killed hook was just for use by (diff) | |
download | apache2-3c0476fe509b3d8bc4839a266f5de9138c73acda.tar.xz apache2-3c0476fe509b3d8bc4839a266f5de9138c73acda.zip |
Simplify the interface to ap_reclaim_child_processes() and
ap_relieve_child_processes(): instead of requiring the MPM
to implement an otherwise-useless hook, just use a callback
function.
As I don't expect third-party MPM devs are following our day
to day progress, the API changes are considered part of
yesterday's MMN change.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1087085 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'server')
-rw-r--r-- | server/mpm/event/event.c | 16 | ||||
-rw-r--r-- | server/mpm/prefork/prefork.c | 14 | ||||
-rw-r--r-- | server/mpm/worker/worker.c | 16 | ||||
-rw-r--r-- | server/mpm_common.c | 5 | ||||
-rw-r--r-- | server/mpm_unix.c | 9 |
5 files changed, 28 insertions, 32 deletions
diff --git a/server/mpm/event/event.c b/server/mpm/event/event.c index 9d9231ce1c..6efd2f73e2 100644 --- a/server/mpm/event/event.c +++ b/server/mpm/event/event.c @@ -424,10 +424,9 @@ static int event_query(int query_code, int *result, apr_status_t *rv) return OK; } -static apr_status_t event_note_child_killed(int childnum) +static void event_note_child_killed(int childnum) { ap_scoreboard_image->parent[childnum].pid = 0; - return APR_SUCCESS; } static const char *event_get_name(void) @@ -2256,7 +2255,8 @@ static int event_run(apr_pool_t * _pconf, apr_pool_t * plog, server_rec * s) * Kill child processes, tell them to call child_exit, etc... */ ap_event_pod_killpg(pod, ap_daemons_limit, FALSE); - ap_reclaim_child_processes(1); /* Start with SIGTERM */ + ap_reclaim_child_processes(1, /* Start with SIGTERM */ + event_note_child_killed); if (!child_fatal) { /* cleanup pid file on normal shutdown */ @@ -2276,7 +2276,7 @@ static int event_run(apr_pool_t * _pconf, apr_pool_t * plog, server_rec * s) /* Close our listeners, and then ask our children to do same */ ap_close_listeners(); ap_event_pod_killpg(pod, ap_daemons_limit, TRUE); - ap_relieve_child_processes(); + ap_relieve_child_processes(event_note_child_killed); if (!child_fatal) { /* cleanup pid file on normal shutdown */ @@ -2298,7 +2298,7 @@ static int event_run(apr_pool_t * _pconf, apr_pool_t * plog, server_rec * s) apr_sleep(apr_time_from_sec(1)); /* Relieve any children which have now exited */ - ap_relieve_child_processes(); + ap_relieve_child_processes(event_note_child_killed); active_children = 0; for (index = 0; index < ap_daemons_limit; ++index) { @@ -2316,7 +2316,7 @@ static int event_run(apr_pool_t * _pconf, apr_pool_t * plog, server_rec * s) * really dead. */ ap_event_pod_killpg(pod, ap_daemons_limit, FALSE); - ap_reclaim_child_processes(1); + ap_reclaim_child_processes(1, event_note_child_killed); return DONE; } @@ -2356,7 +2356,8 @@ static int event_run(apr_pool_t * _pconf, apr_pool_t * plog, server_rec * s) */ ap_event_pod_killpg(pod, ap_daemons_limit, FALSE); - ap_reclaim_child_processes(1); /* Start with SIGTERM */ + ap_reclaim_child_processes(1, /* Start with SIGTERM */ + event_note_child_killed); ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf, "SIGHUP received. Attempting to restart"); } @@ -2720,7 +2721,6 @@ static void event_hooks(apr_pool_t * p) ap_hook_check_config(event_check_config, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_mpm(event_run, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_mpm_query(event_query, NULL, NULL, APR_HOOK_MIDDLE); - ap_hook_mpm_note_child_killed(event_note_child_killed, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_mpm_register_timed_callback(event_register_timed_callback, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_mpm_get_name(event_get_name, NULL, NULL, APR_HOOK_MIDDLE); diff --git a/server/mpm/prefork/prefork.c b/server/mpm/prefork/prefork.c index 87545bfc8f..86c8d8c15d 100644 --- a/server/mpm/prefork/prefork.c +++ b/server/mpm/prefork/prefork.c @@ -306,10 +306,9 @@ static int prefork_query(int query_code, int *result, apr_status_t *rv) return OK; } -static apr_status_t prefork_note_child_killed(int childnum) +static void prefork_note_child_killed(int childnum) { ap_scoreboard_image->parent[childnum].pid = 0; - return APR_SUCCESS; } static const char *prefork_get_name(void) @@ -1059,7 +1058,8 @@ static int prefork_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s) if (ap_unixd_killpg(getpgrp(), SIGTERM) < 0) { ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "killpg SIGTERM"); } - ap_reclaim_child_processes(1); /* Start with SIGTERM */ + ap_reclaim_child_processes(1, /* Start with SIGTERM */ + prefork_note_child_killed); /* cleanup pid file on normal shutdown */ ap_remove_pid(pconf, ap_pid_fname); @@ -1093,7 +1093,7 @@ static int prefork_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s) } /* Allow each child which actually finished to exit */ - ap_relieve_child_processes(); + ap_relieve_child_processes(prefork_note_child_killed); /* cleanup pid file */ ap_remove_pid(pconf, ap_pid_fname); @@ -1112,7 +1112,7 @@ static int prefork_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s) sleep(1); /* Relieve any children which have now exited */ - ap_relieve_child_processes(); + ap_relieve_child_processes(prefork_note_child_killed); active_children = 0; for (index = 0; index < ap_daemons_limit; ++index) { @@ -1180,7 +1180,8 @@ static int prefork_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s) if (ap_unixd_killpg(getpgrp(), SIGHUP) < 0) { ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "killpg SIGHUP"); } - ap_reclaim_child_processes(0); /* Not when just starting up */ + ap_reclaim_child_processes(0, /* Not when just starting up */ + prefork_note_child_killed); ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf, "SIGHUP received. Attempting to restart"); } @@ -1415,7 +1416,6 @@ static void prefork_hooks(apr_pool_t *p) ap_hook_check_config(prefork_check_config, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_mpm(prefork_run, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_mpm_query(prefork_query, NULL, NULL, APR_HOOK_MIDDLE); - ap_hook_mpm_note_child_killed(prefork_note_child_killed, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_mpm_get_name(prefork_get_name, NULL, NULL, APR_HOOK_MIDDLE); } diff --git a/server/mpm/worker/worker.c b/server/mpm/worker/worker.c index de98b52ad1..705451bd22 100644 --- a/server/mpm/worker/worker.c +++ b/server/mpm/worker/worker.c @@ -372,10 +372,9 @@ static int worker_query(int query_code, int *result, apr_status_t *rv) return OK; } -static apr_status_t worker_note_child_killed(int childnum) +static void worker_note_child_killed(int childnum) { ap_scoreboard_image->parent[childnum].pid = 0; - return APR_SUCCESS; } static const char *worker_get_name(void) @@ -1774,7 +1773,8 @@ static int worker_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s) * Kill child processes, tell them to call child_exit, etc... */ ap_worker_pod_killpg(pod, ap_daemons_limit, FALSE); - ap_reclaim_child_processes(1); /* Start with SIGTERM */ + ap_reclaim_child_processes(1, /* Start with SIGTERM */ + worker_note_child_killed); if (!child_fatal) { /* cleanup pid file on normal shutdown */ @@ -1794,7 +1794,7 @@ static int worker_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s) /* Close our listeners, and then ask our children to do same */ ap_close_listeners(); ap_worker_pod_killpg(pod, ap_daemons_limit, TRUE); - ap_relieve_child_processes(); + ap_relieve_child_processes(worker_note_child_killed); if (!child_fatal) { /* cleanup pid file on normal shutdown */ @@ -1816,7 +1816,7 @@ static int worker_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s) apr_sleep(apr_time_from_sec(1)); /* Relieve any children which have now exited */ - ap_relieve_child_processes(); + ap_relieve_child_processes(worker_note_child_killed); active_children = 0; for (index = 0; index < ap_daemons_limit; ++index) { @@ -1834,7 +1834,7 @@ static int worker_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s) * really dead. */ ap_worker_pod_killpg(pod, ap_daemons_limit, FALSE); - ap_reclaim_child_processes(1); + ap_reclaim_child_processes(1, worker_note_child_killed); return DONE; } @@ -1873,7 +1873,8 @@ static int worker_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s) */ ap_worker_pod_killpg(pod, ap_daemons_limit, FALSE); - ap_reclaim_child_processes(1); /* Start with SIGTERM */ + ap_reclaim_child_processes(1, /* Start with SIGTERM */ + worker_note_child_killed); ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf, "SIGHUP received. Attempting to restart"); } @@ -2227,7 +2228,6 @@ static void worker_hooks(apr_pool_t *p) ap_hook_check_config(worker_check_config, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_mpm(worker_run, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_mpm_query(worker_query, NULL, NULL, APR_HOOK_MIDDLE); - ap_hook_mpm_note_child_killed(worker_note_child_killed, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_mpm_get_name(worker_get_name, NULL, NULL, APR_HOOK_MIDDLE); } diff --git a/server/mpm_common.c b/server/mpm_common.c index 11e5af185f..99240a0b6a 100644 --- a/server/mpm_common.c +++ b/server/mpm_common.c @@ -65,7 +65,6 @@ APR_HOOK_STRUCT( APR_HOOK_LINK(drop_privileges) APR_HOOK_LINK(mpm) APR_HOOK_LINK(mpm_query) - APR_HOOK_LINK(mpm_note_child_killed) APR_HOOK_LINK(mpm_register_timed_callback) APR_HOOK_LINK(mpm_get_name) ) @@ -77,7 +76,6 @@ APR_HOOK_STRUCT( APR_HOOK_LINK(drop_privileges) APR_HOOK_LINK(mpm) APR_HOOK_LINK(mpm_query) - APR_HOOK_LINK(mpm_note_child_killed) APR_HOOK_LINK(mpm_register_timed_callback) APR_HOOK_LINK(mpm_get_name) ) @@ -93,9 +91,6 @@ AP_IMPLEMENT_HOOK_RUN_FIRST(int, mpm, AP_IMPLEMENT_HOOK_RUN_FIRST(int, mpm_query, (int query_code, int *result, apr_status_t *_rv), (query_code, result, _rv), DECLINED) -AP_IMPLEMENT_HOOK_RUN_FIRST(apr_status_t, mpm_note_child_killed, - (int childnum), - (childnum), APR_ENOTIMPL) AP_IMPLEMENT_HOOK_RUN_FIRST(apr_status_t, mpm_register_timed_callback, (apr_time_t t, ap_mpm_callback_fn_t *cbfn, void *baton), (t, cbfn, baton), APR_ENOTIMPL) diff --git a/server/mpm_unix.c b/server/mpm_unix.c index b898123424..32ad1f70a7 100644 --- a/server/mpm_unix.c +++ b/server/mpm_unix.c @@ -165,7 +165,8 @@ static int reclaim_one_pid(pid_t pid, action_t action) return 0; } -void ap_reclaim_child_processes(int terminate) +void ap_reclaim_child_processes(int terminate, + ap_reclaim_callback_fn_t *mpm_callback) { apr_time_t waittime = 1024 * 16; int i; @@ -228,7 +229,7 @@ void ap_reclaim_child_processes(int terminate) } if (reclaim_one_pid(pid, action_table[cur_action].action)) { - ap_run_mpm_note_child_killed(i); + mpm_callback(i); } else { ++not_dead_yet; @@ -255,7 +256,7 @@ void ap_reclaim_child_processes(int terminate) action_table[cur_action].action != GIVEUP); } -void ap_relieve_child_processes(void) +void ap_relieve_child_processes(ap_reclaim_callback_fn_t *mpm_callback) { int i; extra_process_t *cur_extra; @@ -273,7 +274,7 @@ void ap_relieve_child_processes(void) } if (reclaim_one_pid(pid, DO_NOTHING)) { - ap_run_mpm_note_child_killed(i); + mpm_callback(i); } } |