]> granicus.if.org Git - apache/commitdiff
Fix startup segfault when the Mutex directive is used but no loaded
authorJeff Trawick <trawick@apache.org>
Mon, 22 Feb 2010 17:16:29 +0000 (17:16 +0000)
committerJeff Trawick <trawick@apache.org>
Mon, 22 Feb 2010 17:16:29 +0000 (17:16 +0000)
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
include/util_mutex.h
server/core.c
server/util_mutex.c

diff --git a/CHANGES b/CHANGES
index 047a2cb30cf3a3fb72d49ad1743a0e798dbc9cd0..cedc8765b8c405f90e67d42390ae9a1ed5f90dfc 100644 (file)
--- 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.
index e9dde52705d2f8af65a608a486763b0a4e6be6d8..935e94e998e3f1c6e4b224100eea5fba3ac61324 100644 (file)
@@ -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()
index df0cdf12b5fceb0924e39e65c2c46f81abfa1cb2..bd66dc3e1d058a65a0dabdfaf7ef98b7525b9659 100644 (file)
@@ -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);
index 0f654882fdbcb432088be3ecd5607f2b2366f762..45f93b48a5706e418394a751e731a460c5b6f56c 100644 (file)
@@ -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) {