]> granicus.if.org Git - apache/commitdiff
Merge r1809302, r1809303, r1809305, r1809311, r1809314, r1809713 from trunk:
authorYann Ylavic <ylavic@apache.org>
Sat, 13 Jan 2018 15:49:17 +0000 (15:49 +0000)
committerYann Ylavic <ylavic@apache.org>
Sat, 13 Jan 2018 15:49:17 +0000 (15:49 +0000)
config: allow to specify flags when registering modules.

First one is AP_MODULE_FLAG_ALWAYS_MERGE.

mod_ssl: follow up to r1809302.

Make use of AP_MODULE_FLAG_ALWAYS_MERGE.

config: follow up to r1809302.
We need to check that the module itself is at the right version.

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.

config: follow up to r1809302.
Associate ap_get_module_flags() to MMN bump.

On the trunk:

mod_ssl: make the new module flag used.

Submitted by: ylavic, icing
Reviewed by: icing, ylavic, covener

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1821071 13f79535-47bb-0310-9956-ffa450edef68

include/ap_mmn.h
include/http_config.h
modules/ssl/mod_ssl.c
server/config.c
server/util_debug.c

index 48c19cb7fd57a8602971e7e1f54e1581275a172c..379b877611e729f5611255ec6cc53cf39814ed26 100644 (file)
  * 20120211.68 (2.4.26-dev) Add ap_get_basic_auth_components() and deprecate
  *                          ap_get_basic_auth_pw()
  * 20120211.69 (2.4.30-dev) Add ap_update_sb_handle()
+ * 20120211.70 (2.4.30-dev) Add flags field to module_struct and function
+ *                          ap_get_module_flags()
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20120211
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 69                  /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 70                  /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
index 66c5b3192fbbd81780752a7f74753a83c1b74d5e..f3e88a8b8c56f9a9708d323f499f6cf8711c0b1c 100644 (file)
@@ -328,6 +328,12 @@ struct cmd_parms_struct {
 
 };
 
+/**
+ * Flags associated with a module.
+ */
+#define AP_MODULE_FLAG_NONE         (0)
+#define AP_MODULE_FLAG_ALWAYS_MERGE (1 << 0)
+
 /**
  * Module structures.  Just about everything is dispatched through
  * these, directly or indirectly (through the command and handler
@@ -407,6 +413,9 @@ struct module_struct {
      *  @param p the pool to use for all allocations
      */
     void (*register_hooks) (apr_pool_t *p);
+
+    /** A bitmask of AP_MODULE_FLAG_* */
+    int flags;
 };
 
 /**
@@ -519,6 +528,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 20120211
+#define AP_MODULE_FLAGS_MMN_MINOR 70
+#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 a23f2f574d0b125c626f33bd1b284a161b632789..7eea7ce5cc13f7de83fc2578db8063a5432fc5f4 100644 (file)
@@ -713,4 +713,7 @@ module AP_MODULE_DECLARE_DATA ssl_module = {
     ssl_config_server_merge,    /* merge  per-server config structures */
     ssl_config_cmds,            /* table of configuration directives   */
     ssl_register_hooks          /* register hooks */
+#if defined(AP_MODULE_HAS_FLAGS)
+   ,AP_MODULE_FLAG_ALWAYS_MERGE /* flags */
+#endif
 };
index 30bd6d66bd1e8aa904cccd50cced275a42f848f4..71d1d5513f1f04eee30d6539d60601d6b5119541 100644 (file)
@@ -323,24 +323,34 @@ 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 (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 {
+                virt_vector[i] = base_vector[i];
+                df = NULL;
+            }
+        }
+        if (df) {
             virt_vector[i] = (*df)(p, base_vector[i], virt_vector[i]);
+        }
     }
 }
 
@@ -2337,8 +2347,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,
index 41250da62b5953c959c8b5cee6397f6e13c0f185..a75fdda003a1a5961089b4f78ba26ddf538a4ab0 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);