From 83532ab6284ee5d0db23f2368d315a6c788975f0 Mon Sep 17 00:00:00 2001 From: Jim Jagielski Date: Fri, 25 Sep 2009 11:59:30 +0000 Subject: [PATCH] Enhance ap_hook_monitor to pass along a server_rec (in general the ap_server_conf) and tuck away some storage in there which may be useful as an opaque data pointer. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@818825 13f79535-47bb-0310-9956-ffa450edef68 --- include/ap_mmn.h | 2 ++ include/httpd.h | 3 +++ include/mpm_common.h | 3 ++- modules/examples/mod_example_hooks.c | 2 +- modules/experimental/mod_noloris.c | 2 +- modules/session/mod_session_dbd.c | 6 +++--- server/mpm/event/event.c | 2 +- server/mpm/prefork/prefork.c | 2 +- server/mpm/worker/worker.c | 2 +- server/mpm_common.c | 4 ++-- 10 files changed, 17 insertions(+), 11 deletions(-) diff --git a/include/ap_mmn.h b/include/ap_mmn.h index eeec6af8d8..d505475dfa 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -196,6 +196,8 @@ * 20090401.1 (2.3.3-dev) Protected log.c internals, http_log.h changes * 20090401.2 (2.3.3-dev) Added tmp_flush_bb to core_output_filter_ctx_t * 20090401.3 (2.3.3-dev) Added DAV options provider to mod_dav.h + * 20090925.0 (2.3.3-dev) Added server_rec::context and added *server_rec + * param to ap_wait_or_timeout() * */ diff --git a/include/httpd.h b/include/httpd.h index cd47b11132..c5c332e820 100644 --- a/include/httpd.h +++ b/include/httpd.h @@ -1235,6 +1235,9 @@ struct server_rec { /** The server request scheme for redirect responses */ const char *server_scheme; + + /** Opaque storage location */ + void *context; }; typedef struct core_output_filter_ctx { diff --git a/include/mpm_common.h b/include/mpm_common.h index 0e8143b5c3..1ce3abb5c0 100644 --- a/include/mpm_common.h +++ b/include/mpm_common.h @@ -145,9 +145,10 @@ apr_status_t ap_mpm_safe_kill(pid_t pid, int sig); * @param status The return code if a process has died * @param ret The process id of the process that died * @param p The pool to allocate out of + * @param s The server_rec to pass */ void ap_wait_or_timeout(apr_exit_why_e *status, int *exitcode, apr_proc_t *ret, - apr_pool_t *p); + apr_pool_t *p, server_rec *s); /** * Log why a child died to the error log, if the child died without the diff --git a/modules/examples/mod_example_hooks.c b/modules/examples/mod_example_hooks.c index 30ea60fe78..f6b9979329 100644 --- a/modules/examples/mod_example_hooks.c +++ b/modules/examples/mod_example_hooks.c @@ -1399,7 +1399,7 @@ static int x_pre_mpm(apr_pool_t *p, ap_scoreboard_e sb_type) * * This is a RUN_ALL hook. */ -static int x_monitor(apr_pool_t *p) +static int x_monitor(apr_pool_t *p, server_rec *s) { trace_nocontext(p, __FILE__, __LINE__, "x_monitor()"); return DECLINED; diff --git a/modules/experimental/mod_noloris.c b/modules/experimental/mod_noloris.c index 6baa8933bd..75bb9115db 100644 --- a/modules/experimental/mod_noloris.c +++ b/modules/experimental/mod_noloris.c @@ -98,7 +98,7 @@ static int noloris_conn(conn_rec *conn) return DECLINED; } -static int noloris_monitor(apr_pool_t *pool) +static int noloris_monitor(apr_pool_t *pool, server_rec *s) { static apr_hash_t *connections = NULL; static apr_time_t last_check = 0; diff --git a/modules/session/mod_session_dbd.c b/modules/session/mod_session_dbd.c index 7df10cd82d..83aceb8776 100644 --- a/modules/session/mod_session_dbd.c +++ b/modules/session/mod_session_dbd.c @@ -379,7 +379,7 @@ static apr_status_t dbd_remove(request_rec * r, const char *key) * The monitor hook doesn't help us that much, as we have no handle into the * server, and so we need to come up with a way to do this safely. */ -static apr_status_t dbd_clean(apr_pool_t *p) +static apr_status_t dbd_clean(apr_pool_t *p, server_rec *s) { return APR_ENOTIMPL; @@ -471,10 +471,10 @@ static int session_dbd_save(request_rec * r, session_rec * z) * This function performs housekeeping on the database, deleting expired * sessions. */ -static int session_dbd_monitor(apr_pool_t *p) +static int session_dbd_monitor(apr_pool_t *p, server_rec *s) { /* TODO handle housekeeping */ - dbd_clean(p); + dbd_clean(p, s); return OK; } diff --git a/server/mpm/event/event.c b/server/mpm/event/event.c index cb5c9427a5..3cacb23dcf 100644 --- a/server/mpm/event/event.c +++ b/server/mpm/event/event.c @@ -2109,7 +2109,7 @@ static void server_main_loop(int remaining_children_to_start) int i; while (!restart_pending && !shutdown_pending) { - ap_wait_or_timeout(&exitwhy, &status, &pid, pconf); + ap_wait_or_timeout(&exitwhy, &status, &pid, pconf, ap_server_conf); if (pid.pid != -1) { processed_status = ap_process_child_status(&pid, exitwhy, status); diff --git a/server/mpm/prefork/prefork.c b/server/mpm/prefork/prefork.c index 9b30635fc8..91d8ae81bb 100644 --- a/server/mpm/prefork/prefork.c +++ b/server/mpm/prefork/prefork.c @@ -1002,7 +1002,7 @@ static int prefork_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s) /* this is a memory leak, but I'll fix it later. */ apr_proc_t pid; - ap_wait_or_timeout(&exitwhy, &status, &pid, pconf); + ap_wait_or_timeout(&exitwhy, &status, &pid, pconf, ap_server_conf); /* XXX: if it takes longer than 1 second for all our children * to start up and get into IDLE state then we may spawn an diff --git a/server/mpm/worker/worker.c b/server/mpm/worker/worker.c index 92b26fe455..aa397475a1 100644 --- a/server/mpm/worker/worker.c +++ b/server/mpm/worker/worker.c @@ -1604,7 +1604,7 @@ static void server_main_loop(int remaining_children_to_start) int i; while (!restart_pending && !shutdown_pending) { - ap_wait_or_timeout(&exitwhy, &status, &pid, pconf); + ap_wait_or_timeout(&exitwhy, &status, &pid, pconf, ap_server_conf); if (pid.pid != -1) { processed_status = ap_process_child_status(&pid, exitwhy, status); diff --git a/server/mpm_common.c b/server/mpm_common.c index 6988374d01..65fff4e354 100644 --- a/server/mpm_common.c +++ b/server/mpm_common.c @@ -108,14 +108,14 @@ AP_IMPLEMENT_HOOK_RUN_FIRST(const char *, mpm_get_name, static int wait_or_timeout_counter; void ap_wait_or_timeout(apr_exit_why_e *status, int *exitcode, apr_proc_t *ret, - apr_pool_t *p) + apr_pool_t *p, server_rec *s) { apr_status_t rv; ++wait_or_timeout_counter; if (wait_or_timeout_counter == INTERVAL_OF_WRITABLE_PROBES) { wait_or_timeout_counter = 0; - ap_run_monitor(p); + ap_run_monitor(p, s); } rv = apr_proc_wait_all_procs(ret, exitcode, status, APR_NOWAIT, p); -- 2.50.1