From: Stefan Fritsch Date: Sat, 21 Aug 2010 18:06:41 +0000 (+0000) Subject: core: Abort with sensible error message if no or more than one MPM is X-Git-Tag: 2.3.8~12 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8f840cb763aa67f331cecc4e5e850bb07d2a9943;p=apache core: Abort with sensible error message if no or more than one MPM is loaded. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@987806 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 7611792400..54e5890f8e 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ Changes with Apache 2.3.8 + *) core: Abort with sensible error message if no or more than one MPM is + loaded. [Stefan Fritsch] + *) mod_proxy: Rename erroronstatus to failonstatus. [Daniel Ruggeri ] diff --git a/include/ap_mmn.h b/include/ap_mmn.h index b97547f168..40860edd90 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -244,6 +244,7 @@ * 20100723.1 (2.3.7-dev) Added ap_proxy_hashfunc() and hash elements to * proxy worker structs * 20100723.2 (2.3.7-dev) Add ap_request_has_body() + * 20100723.3 (2.3.8-dev) Add ap_check_mpm() */ #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */ @@ -251,7 +252,7 @@ #ifndef MODULE_MAGIC_NUMBER_MAJOR #define MODULE_MAGIC_NUMBER_MAJOR 20100723 #endif -#define MODULE_MAGIC_NUMBER_MINOR 2 /* 0...n */ +#define MODULE_MAGIC_NUMBER_MINOR 3 /* 0...n */ /** * Determine if the server's current MODULE_MAGIC_NUMBER is at least a diff --git a/include/mpm_common.h b/include/mpm_common.h index ebca2b766f..fc6ee1c098 100644 --- a/include/mpm_common.h +++ b/include/mpm_common.h @@ -242,6 +242,12 @@ AP_DECLARE(apr_status_t) ap_mpm_pod_signal(ap_pod_t *pod); */ AP_DECLARE(void) ap_mpm_pod_killpg(ap_pod_t *pod, int num); +/** + * Check that exactly one MPM is loaded + * Returns NULL if yes, error string if not. + */ +AP_DECLARE(const char *) ap_check_mpm(void); + /* * These data members are common to all mpms. Each new mpm * should either use the appropriate ap_mpm_set_* function diff --git a/server/config.c b/server/config.c index b58f096939..ea54280ea4 100644 --- a/server/config.c +++ b/server/config.c @@ -49,6 +49,7 @@ #include "http_main.h" #include "http_vhost.h" #include "util_cfgtree.h" +#include "mpm_common.h" #define APLOG_UNSET (APLOG_NO_MODULE - 1) APLOG_USE_MODULE(core); @@ -2242,6 +2243,13 @@ AP_DECLARE(server_rec*) ap_read_config(process_rec *process, apr_pool_t *ptemp, return NULL; } + error = ap_check_mpm(); + if (error) { + ap_log_error(APLOG_MARK, APLOG_STARTUP|APLOG_CRIT, 0, NULL, + "%s: Configuration error: %s", ap_server_argv0, error); + return NULL; + } + /* * We have loaded the dynamic modules. From now on we know exactly how * long the config vectors need to be. diff --git a/server/mpm_common.c b/server/mpm_common.c index 56bc70c875..e45a089447 100644 --- a/server/mpm_common.c +++ b/server/mpm_common.c @@ -375,3 +375,13 @@ AP_DECLARE(const char *)ap_show_mpm(void) return name; } + +AP_DECLARE(const char *)ap_check_mpm(void) +{ + if (!_hooks.link_mpm || _hooks.link_mpm->nelts == 0) + return "No MPM loaded."; + else if (_hooks.link_mpm->nelts > 1) + return "More than one MPM loaded."; + else + return NULL; +}