On Thu, Sep 21, 2017 at 2:11 PM, Eric Covener <cove...@gmail.com> wrote: > > IIUC it should be safe to extend module_struct with a minor bump to > add 'int flags' to the bottom, but when you check the value you'd need > to check the MMN first. In the module you'd then just have some flags > or'ed together after register_hooks.
Something like the attached patch might do it (untested, no MMN minor bump). > > (hopefully someone will check my work) Since modules (module_struct) are déclared globally, unspecified fields at the end of the struct should be initialized to zero, so it should be safe.
Index: include/http_config.h =================================================================== --- include/http_config.h (revision 1809129) +++ include/http_config.h (working copy) @@ -329,6 +329,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 * tables). @@ -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; }; /** Index: server/config.c =================================================================== --- server/config.c (revision 1809129) +++ server/config.c (working copy) @@ -323,7 +323,7 @@ static ap_conf_vector_t *create_server_config(apr_ } 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... @@ -330,7 +330,7 @@ static void merge_server_configs(apr_pool_t *p, ap */ 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) { @@ -337,10 +337,19 @@ static void merge_server_configs(apr_pool_t *p, ap 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 + && modp->flags & 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]); + } } } @@ -2322,8 +2331,7 @@ AP_DECLARE(void) ap_fixup_virtual_hosts(apr_pool_t 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: modules/ssl/mod_ssl.c =================================================================== --- modules/ssl/mod_ssl.c (revision 1809129) +++ modules/ssl/mod_ssl.c (working copy) @@ -712,5 +712,6 @@ module AP_MODULE_DECLARE_DATA ssl_module = { ssl_config_server_create, /* create per-server config structures */ ssl_config_server_merge, /* merge per-server config structures */ ssl_config_cmds, /* table of configuration directives */ - ssl_register_hooks /* register hooks */ + ssl_register_hooks, /* register hooks */ + AP_MODULE_FLAG_ALWAYS_MERGE /* flags */ };