[1602] | 1 | commit 3b081163d6250d893838d69d9a83f217c341d657 |
---|
| 2 | Author: Greg Brockman <gdb@mit.edu> |
---|
| 3 | Date: Fri Aug 6 23:19:15 2010 -0400 |
---|
| 4 | |
---|
| 5 | Add method to merge virtual host with a main server_rec |
---|
| 6 | |
---|
| 7 | diff --git a/include/http_config.h b/include/http_config.h |
---|
| 8 | index 5e9fd51..8e6f247 100644 |
---|
| 9 | --- a/include/http_config.h |
---|
| 10 | +++ b/include/http_config.h |
---|
| 11 | @@ -827,6 +827,16 @@ AP_DECLARE(void) ap_register_hooks(module *m, apr_pool_t *p); |
---|
| 12 | AP_DECLARE(void) ap_fixup_virtual_hosts(apr_pool_t *p, |
---|
| 13 | server_rec *main_server); |
---|
| 14 | |
---|
| 15 | +/** |
---|
| 16 | + * Setup a single virtual host by merging the main server_rec into it. |
---|
| 17 | + * @param p The pool to allocate from |
---|
| 18 | + * @param main_server The server_rec with which to merge |
---|
| 19 | + * @param virt The virtual host server_rec with some set of directives to override already set |
---|
| 20 | + */ |
---|
| 21 | +AP_DECLARE(void) ap_fixup_virtual_host(apr_pool_t *p, |
---|
| 22 | + server_rec *main_server, |
---|
| 23 | + server_rec *virt); |
---|
| 24 | + |
---|
| 25 | /* For http_request.c... */ |
---|
| 26 | |
---|
| 27 | /** |
---|
| 28 | diff --git a/server/config.c b/server/config.c |
---|
| 29 | index 101d0e4..ef0f2ba 100644 |
---|
| 30 | --- a/server/config.c |
---|
| 31 | +++ b/server/config.c |
---|
| 32 | @@ -1902,38 +1902,43 @@ AP_CORE_DECLARE(const char *) ap_init_virtual_host(apr_pool_t *p, |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | |
---|
| 36 | -AP_DECLARE(void) ap_fixup_virtual_hosts(apr_pool_t *p, server_rec *main_server) |
---|
| 37 | +AP_DECLARE(void) ap_fixup_virtual_host(apr_pool_t *p, server_rec *main_server, |
---|
| 38 | + server_rec *virt) |
---|
| 39 | { |
---|
| 40 | - server_rec *virt; |
---|
| 41 | + merge_server_configs(p, main_server->module_config, |
---|
| 42 | + virt->module_config); |
---|
| 43 | |
---|
| 44 | - for (virt = main_server->next; virt; virt = virt->next) { |
---|
| 45 | - merge_server_configs(p, main_server->module_config, |
---|
| 46 | - virt->module_config); |
---|
| 47 | + virt->lookup_defaults = |
---|
| 48 | + ap_merge_per_dir_configs(p, main_server->lookup_defaults, |
---|
| 49 | + virt->lookup_defaults); |
---|
| 50 | |
---|
| 51 | - virt->lookup_defaults = |
---|
| 52 | - ap_merge_per_dir_configs(p, main_server->lookup_defaults, |
---|
| 53 | - virt->lookup_defaults); |
---|
| 54 | + if (virt->server_admin == NULL) |
---|
| 55 | + virt->server_admin = main_server->server_admin; |
---|
| 56 | |
---|
| 57 | - if (virt->server_admin == NULL) |
---|
| 58 | - virt->server_admin = main_server->server_admin; |
---|
| 59 | + if (virt->timeout == 0) |
---|
| 60 | + virt->timeout = main_server->timeout; |
---|
| 61 | |
---|
| 62 | - if (virt->timeout == 0) |
---|
| 63 | - virt->timeout = main_server->timeout; |
---|
| 64 | + if (virt->keep_alive_timeout == 0) |
---|
| 65 | + virt->keep_alive_timeout = main_server->keep_alive_timeout; |
---|
| 66 | |
---|
| 67 | - if (virt->keep_alive_timeout == 0) |
---|
| 68 | - virt->keep_alive_timeout = main_server->keep_alive_timeout; |
---|
| 69 | + if (virt->keep_alive == -1) |
---|
| 70 | + virt->keep_alive = main_server->keep_alive; |
---|
| 71 | |
---|
| 72 | - if (virt->keep_alive == -1) |
---|
| 73 | - virt->keep_alive = main_server->keep_alive; |
---|
| 74 | + if (virt->keep_alive_max == -1) |
---|
| 75 | + virt->keep_alive_max = main_server->keep_alive_max; |
---|
| 76 | |
---|
| 77 | - if (virt->keep_alive_max == -1) |
---|
| 78 | - virt->keep_alive_max = main_server->keep_alive_max; |
---|
| 79 | + /* XXX: this is really something that should be dealt with by a |
---|
| 80 | + * post-config api phase |
---|
| 81 | + */ |
---|
| 82 | + ap_core_reorder_directories(p, virt); |
---|
| 83 | +} |
---|
| 84 | |
---|
| 85 | - /* XXX: this is really something that should be dealt with by a |
---|
| 86 | - * post-config api phase |
---|
| 87 | - */ |
---|
| 88 | - ap_core_reorder_directories(p, virt); |
---|
| 89 | - } |
---|
| 90 | +AP_DECLARE(void) ap_fixup_virtual_hosts(apr_pool_t *p, server_rec *main_server) |
---|
| 91 | +{ |
---|
| 92 | + server_rec *virt; |
---|
| 93 | + |
---|
| 94 | + for (virt = main_server->next; virt; virt = virt->next) |
---|
| 95 | + ap_fixup_virtual_host(p, main_server, virt); |
---|
| 96 | |
---|
| 97 | ap_core_reorder_directories(p, main_server); |
---|
| 98 | } |
---|