]> granicus.if.org Git - apache/commitdiff
config: follow up to r1809302.
authorYann Ylavic <ylavic@apache.org>
Fri, 22 Sep 2017 13:13:44 +0000 (13:13 +0000)
committerYann Ylavic <ylavic@apache.org>
Fri, 22 Sep 2017 13:13:44 +0000 (13:13 +0000)
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

include/http_config.h
server/config.c
server/util_debug.c

index cfc0c3233cd32a6d6edb7c0779f17b7de42e3ab6..37e0b382abe739d303a56153735d2ea656fa0f63 100644 (file)
@@ -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)       \
index 12552c6474be0554ae4c1c1d0ee8be9ab3ef2845..8e30341a6d095d7e0b559b3a3b42bf1ed92449aa 100644 (file)
@@ -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;
             }
index 52f9415bbdcf9ca29f20e50305e8ebc11379d840..3634402b64550b63633b206894a7531d632ac3ff 100644 (file)
@@ -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);