]> granicus.if.org Git - apache/commitdiff
config: allow to specify flags when registering modules.
authorYann Ylavic <ylavic@apache.org>
Fri, 22 Sep 2017 11:58:53 +0000 (11:58 +0000)
committerYann Ylavic <ylavic@apache.org>
Fri, 22 Sep 2017 11:58:53 +0000 (11:58 +0000)
First one is AP_MODULE_FLAG_ALWAYS_MERGE.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1809302 13f79535-47bb-0310-9956-ffa450edef68

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

index 526cd3d3dafa7cbba18d932a3eab329f00ae2de2..95cf8d796ebe0a891c52b800ea7bf2eb45133d06 100644 (file)
  * 20161018.5 (2.5.0-dev)  Add ap_get_basic_auth_components() and deprecate
  *                         ap_get_basic_auth_pw()
  * 20161018.6 (2.5.0-dev)  Add ap_update_sb_handle()
+ * 20161018.7 (2.5.0-dev)  Add flags field to module_struct
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20161018
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 6                 /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 7                 /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
index 758ba7a108d2d4beb5f6a4643c9f39c6dd109609..9adfcbf9a7326627513131104fa8ca2cb7c94aaa 100644 (file)
@@ -333,6 +333,16 @@ struct cmd_parms_struct {
     ap_directive_t *parent;
 };
 
+#define AP_MODULE_HAS_FLAGS \
+        AP_MODULE_MAGIC_AT_LEAST(20161018,7)
+#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
  * these, directly or indirectly (through the command and handler
@@ -412,6 +422,11 @@ struct module_struct {
      *  @param p the pool to use for all allocations
      */
     void (*register_hooks) (apr_pool_t *p);
+
+#if AP_MODULE_HAS_FLAGS
+    /** A bitmask of AP_MODULE_FLAG_* */
+    int flags;
+#endif
 };
 
 /**
index 8c8acbcb2d97831edb2ef423380d45d95afdd924..74674a52fcc232a7fda06edcefcebf4177402e14 100644 (file)
@@ -323,24 +323,36 @@ static ap_conf_vector_t *create_server_config(apr_pool_t *p, server_rec *s)
 }
 
 static void merge_server_configs(apr_pool_t *p, ap_conf_vector_t *base,
-                                 ap_conf_vector_t *virt)
+                                 server_rec *virt)
 {
     /* Can reuse the 'virt' vector for the spine of it, since we don't
      * have to deal with the moral equivalent of .htaccess files here...
      */
 
     void **base_vector = (void **)base;
-    void **virt_vector = (void **)virt;
+    void **virt_vector = (void **)virt->module_config;
     module *modp;
 
     for (modp = ap_top_module; modp; modp = modp->next) {
         merger_func df = modp->merge_server_config;
         int i = modp->module_index;
 
-        if (!virt_vector[i])
-            virt_vector[i] = base_vector[i];
-        else if (df)
+        if (!virt_vector[i]) {
+#if AP_MODULE_HAS_FLAGS
+            if (df && modp->create_server_config
+                   && modp->flags & AP_MODULE_FLAG_ALWAYS_MERGE) {
+                virt_vector[i] = (*modp->create_server_config)(p, virt);
+            }
+            else
+#endif
+            {
+                virt_vector[i] = base_vector[i];
+                df = NULL;
+            }
+        }
+        if (df) {
             virt_vector[i] = (*df)(p, base_vector[i], virt_vector[i]);
+        }
     }
 }
 
@@ -2334,8 +2346,7 @@ AP_DECLARE(void) ap_fixup_virtual_hosts(apr_pool_t *p, server_rec *main_server)
     dconf->log = &main_server->log;
 
     for (virt = main_server->next; virt; virt = virt->next) {
-        merge_server_configs(p, main_server->module_config,
-                             virt->module_config);
+        merge_server_configs(p, main_server->module_config, virt);
 
         virt->lookup_defaults =
             ap_merge_per_dir_configs(p, main_server->lookup_defaults,