From ec56aba06fbeabc8349dd81483f66fbb66aeeea2 Mon Sep 17 00:00:00 2001 From: Jeff Trawick Date: Mon, 22 Feb 2010 17:16:29 +0000 Subject: [PATCH] Fix startup segfault when the Mutex directive is used but no loaded modules use httpd mutexes. Add an init call from core's pre-config hook to ensure init is performed before the config is parsed. PR: 48787 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@912666 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 3 +++ include/util_mutex.h | 3 +++ server/core.c | 8 ++++++++ server/util_mutex.c | 4 ++-- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 047a2cb30c..cedc8765b8 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ Changes with Apache 2.3.7 + *) Fix startup segfault when the Mutex directive is used but no loaded + modules use httpd mutexes. PR 48787. [Jeff Trawick] + *) Proxy: get the headers right in a HEAD request with ProxyErrorOverride, by checking for an overridden error before not after going into a catch-all code path. diff --git a/include/util_mutex.h b/include/util_mutex.h index e9dde52705..935e94e998 100644 --- a/include/util_mutex.h +++ b/include/util_mutex.h @@ -103,6 +103,9 @@ AP_DECLARE(apr_status_t) ap_parse_mutex(const char *arg, apr_pool_t *pool, AP_DECLARE_NONSTD(const char *) ap_set_mutex(cmd_parms *cmd, void *dummy, const char *arg); +/* private function to initialize Mutex infrastructure */ +AP_DECLARE_NONSTD(void) ap_mutex_init(apr_pool_t *p); + /** * option flags for ap_mutex_register(), ap_global_mutex_create(), and * ap_proc_mutex_create() diff --git a/server/core.c b/server/core.c index df0cdf12b5..bd66dc3e1d 100644 --- a/server/core.c +++ b/server/core.c @@ -3714,6 +3714,13 @@ AP_DECLARE(int) ap_sys_privileges_handlers(int inc) sys_privileges += inc; return sys_privileges; } + +static int core_pre_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp) +{ + ap_mutex_init(pconf); + return APR_SUCCESS; +} + static int core_post_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s) { ap__logio_add_bytes_out = APR_RETRIEVE_OPTIONAL_FN(ap_logio_add_bytes_out); @@ -3932,6 +3939,7 @@ static void register_hooks(apr_pool_t *p) ap_hook_pre_connection(core_pre_connection, NULL, NULL, APR_HOOK_REALLY_LAST); + ap_hook_pre_config(core_pre_config, NULL, NULL, APR_HOOK_REALLY_FIRST); ap_hook_post_config(core_post_config,NULL,NULL,APR_HOOK_REALLY_FIRST); ap_hook_translate_name(ap_core_translate,NULL,NULL,APR_HOOK_REALLY_LAST); ap_hook_map_to_storage(core_map_to_storage,NULL,NULL,APR_HOOK_REALLY_LAST); diff --git a/server/util_mutex.c b/server/util_mutex.c index 0f654882fd..45f93b48a5 100644 --- a/server/util_mutex.c +++ b/server/util_mutex.c @@ -143,7 +143,7 @@ static apr_status_t cleanup_mx_hash(void *dummy) return APR_SUCCESS; } -static void mx_hash_init(apr_pool_t *p) +AP_DECLARE_NONSTD(void) ap_mutex_init(apr_pool_t *p) { mutex_cfg_t *def; @@ -266,7 +266,7 @@ AP_DECLARE(apr_status_t) ap_mutex_register(apr_pool_t *pconf, return APR_EINVAL; } - mx_hash_init(pconf); + ap_mutex_init(pconf); /* in case this mod's pre-config ran before core's */ mxcfg->options = options; if (options & AP_MUTEX_DEFAULT_NONE) { -- 2.50.1