From: Jeff Trawick Date: Wed, 25 Mar 2009 11:23:29 +0000 (+0000) Subject: change the allocation path for the simple MPM's retained data, as a dynamically X-Git-Tag: 2.3.3~824 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=02e79daf0e00d5079a350f62c86735f21bec6cf2;p=apache change the allocation path for the simple MPM's retained data, as a dynamically loadable MPM can't use the rewrite-args hook (note across the table: the hooker hook has no retcode feedback, so I didn't init the data there) git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@758224 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/mpm/simple/simple_api.c b/server/mpm/simple/simple_api.c index d9befb3c96..b6fb66b115 100644 --- a/server/mpm/simple/simple_api.c +++ b/server/mpm/simple/simple_api.c @@ -131,7 +131,18 @@ simple_pre_config(apr_pool_t * pconf, apr_pool_t * plog, apr_pool_t * ptemp) { int run_debug; apr_status_t rv; - simple_core_t *sc = simple_core_get(); + simple_core_t *sc; + + /* this is our first 'real' entry point, so setup everything here. */ + rv = simple_core_init_once(); + + if (rv) { + ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL, + "simple_core_init_once: Fatal Error Encountered"); + return HTTP_INTERNAL_SERVER_ERROR; + } + + sc = simple_core_get(); sc->restart_num++; @@ -165,22 +176,6 @@ simple_pre_config(apr_pool_t * pconf, apr_pool_t * plog, apr_pool_t * ptemp) return OK; } -static void simple_process_start(process_rec * process) -{ - apr_status_t rv; - - /* this is our first 'real' entry point, so setup everything here. */ - rv = simple_core_init(simple_core_get(), process->pool); - - if (rv) { - ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL, - "simple_core_init: Fatal Error Encountered"); - exit(EXIT_FAILURE); - } - - ap_mpm_rewrite_args(process); -} - static int simple_check_config(apr_pool_t * p, apr_pool_t * plog, apr_pool_t * ptemp, server_rec * s) @@ -275,7 +270,7 @@ static const command_rec simple_cmds[] = { module AP_MODULE_DECLARE_DATA mpm_simple_module = { MPM20_MODULE_STUFF, - simple_process_start, /* hook to run before apache parses args */ + ap_mpm_rewrite_args, /* hook to run before apache parses args */ NULL, /* create per-directory config structure */ NULL, /* merge per-directory config structures */ NULL, /* create per-server config structure */ diff --git a/server/mpm/simple/simple_core.c b/server/mpm/simple/simple_core.c index 7a46855693..2fa5adb172 100644 --- a/server/mpm/simple/simple_core.c +++ b/server/mpm/simple/simple_core.c @@ -21,8 +21,10 @@ #include "ap_mpm.h" #include "httpd.h" #include "http_log.h" +#include "http_config.h" +#include "http_main.h" -static simple_core_t g_simple_core; +static simple_core_t *g_simple_core; #ifndef DEFAULT_MAX_REQUESTS_PER_CHILD #define DEFAULT_MAX_REQUESTS_PER_CHILD 0 @@ -31,16 +33,23 @@ static simple_core_t g_simple_core; simple_core_t *simple_core_get() { - return &g_simple_core; + return g_simple_core; } -apr_status_t simple_core_init(simple_core_t * sc, apr_pool_t * pool) +apr_status_t simple_core_init_once(void) { apr_status_t rv; + const char *userdata_key = "mpm_simple_module"; + simple_core_t *sc; - memset(sc, 0, sizeof(simple_core_t)); + g_simple_core = ap_get_retained_data(userdata_key); + if (g_simple_core) { + return APR_SUCCESS; + } + + sc = g_simple_core = ap_set_retained_data(userdata_key, sizeof(*g_simple_core)); - apr_pool_create(&sc->pool, pool); + apr_pool_create(&sc->pool, ap_pglobal); apr_pool_tag(sc->pool, "simple-mpm-core"); @@ -59,7 +68,7 @@ apr_status_t simple_core_init(simple_core_t * sc, apr_pool_t * pool) if (rv) { ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL, - "simple_core_init: apr_thread_mutex_create failed."); + "simple_core_init_once: apr_thread_mutex_create failed."); return rv; } diff --git a/server/mpm/simple/simple_types.h b/server/mpm/simple/simple_types.h index 814165873e..a71691f5f7 100644 --- a/server/mpm/simple/simple_types.h +++ b/server/mpm/simple/simple_types.h @@ -126,7 +126,7 @@ struct simple_conn_t simple_core_t *simple_core_get(void); -/* Resets all variables to 0 for a simple_core_t */ -apr_status_t simple_core_init(simple_core_t * sc, apr_pool_t * pool); +/* Allocates/initializes data retained over the life of the process */ +apr_status_t simple_core_init_once(void); #endif /* APACHE_MPM_SIMPLE_TYPES_H */