From: Yann Ylavic Date: Fri, 22 Sep 2017 13:13:44 +0000 (+0000) Subject: config: follow up to r1809302. X-Git-Tag: 2.5.0-alpha~102 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=91566715427817ae70ec386ae0d283015d5a73ee;p=apache config: follow up to r1809302. Provide a convenient function to get module flags, and remove useless AP_MODULE_HAS_FLAGS checks in the core, core's version is at current MMN. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1809311 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/include/http_config.h b/include/http_config.h index cfc0c3233c..37e0b382ab 100644 --- a/include/http_config.h +++ b/include/http_config.h @@ -333,18 +333,11 @@ struct cmd_parms_struct { ap_directive_t *parent; }; -#define AP_MODULE_FLAGS_MMN_MAJOR 20161018 -#define AP_MODULE_FLAGS_MMN_MINOR 7 -#define AP_MODULE_HAS_FLAGS(m) \ - AP_MODULE_MAGIC_AT_LEAST(AP_MODULE_FLAGS_MMN_MAJOR, \ - AP_MODULE_FLAGS_MMN_MINOR) -#if AP_MODULE_HAS_FLAGS /** * Flags associated with a module. */ #define AP_MODULE_FLAG_NONE (0) #define AP_MODULE_FLAG_ALWAYS_MERGE (1 << 0) -#endif /** * Module structures. Just about everything is dispatched through @@ -426,10 +419,8 @@ struct module_struct { */ void (*register_hooks) (apr_pool_t *p); -#if AP_MODULE_HAS_FLAGS /** A bitmask of AP_MODULE_FLAG_* */ int flags; -#endif }; /** @@ -542,6 +533,21 @@ AP_DECLARE(void *) ap_get_module_config(const ap_conf_vector_t *cv, AP_DECLARE(void) ap_set_module_config(ap_conf_vector_t *cv, const module *m, void *val); +/** + * When module flags have been introduced, and a way to check this. + */ +#define AP_MODULE_FLAGS_MMN_MAJOR 20161018 +#define AP_MODULE_FLAGS_MMN_MINOR 7 +#define AP_MODULE_HAS_FLAGS(m) \ + AP_MODULE_MAGIC_AT_LEAST(AP_MODULE_FLAGS_MMN_MAJOR, \ + AP_MODULE_FLAGS_MMN_MINOR) +/** + * Generic accessor for the module's flags + * @param m The module to get the flags from. + * @return The module-specific flags + */ +AP_DECLARE(int) ap_get_module_flags(const module *m); + #if !defined(AP_DEBUG) #define ap_get_module_config(v,m) \ diff --git a/server/config.c b/server/config.c index 12552c6474..8e30341a6d 100644 --- a/server/config.c +++ b/server/config.c @@ -338,20 +338,12 @@ static void merge_server_configs(apr_pool_t *p, ap_conf_vector_t *base, int i = modp->module_index; if (!virt_vector[i]) { -#if AP_MODULE_HAS_FLAGS - if (df - && modp->create_server_config - && (modp->version > AP_MODULE_FLAGS_MMN_MAJOR - || (modp->version == AP_MODULE_FLAGS_MMN_MAJOR - && (modp->minor_version >= - AP_MODULE_FLAGS_MMN_MINOR))) - /* keep this after version checks (flags out-of-bound) */ - && (modp->flags & AP_MODULE_FLAG_ALWAYS_MERGE)) { + if (df && modp->create_server_config + && (ap_get_module_flags(modp) & + AP_MODULE_FLAG_ALWAYS_MERGE)) { virt_vector[i] = (*modp->create_server_config)(p, virt); } - else -#endif - { + else { virt_vector[i] = base_vector[i]; df = NULL; } diff --git a/server/util_debug.c b/server/util_debug.c index 52f9415bbd..3634402b64 100644 --- a/server/util_debug.c +++ b/server/util_debug.c @@ -107,6 +107,17 @@ AP_DECLARE(void *) ap_get_module_config(const ap_conf_vector_t *cv, return ((void **)cv)[m->module_index]; } +AP_DECLARE(int) ap_get_module_flags(const module *m) +{ + if (m->version < AP_MODULE_FLAGS_MMN_MAJOR + || (m->version == AP_MODULE_FLAGS_MMN_MAJOR + && (m->minor_version < AP_MODULE_FLAGS_MMN_MINOR))) { + return 0; + } + + return m->flags; +} + #if defined(ap_get_core_module_config) #undef ap_get_core_module_config AP_DECLARE(void *) ap_get_core_module_config(const ap_conf_vector_t *cv);