]> granicus.if.org Git - apache/commitdiff
Reorder and correct creation and merge of server records, optimizing
authorWilliam A. Rowe Jr <wrowe@apache.org>
Sat, 3 Jan 2009 19:17:14 +0000 (19:17 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Sat, 3 Jan 2009 19:17:14 +0000 (19:17 +0000)
significantly for all of our null / 0 value defaults (we had always
palloc'ed, so this was very wasteful).

Corrects a segfault in 2.3.1-alpha candidate, which evaluated the
accf_map.  Due to the backwards construction of the merge (patched)
this was never initialized in virtual servers.

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

server/core.c

index 3ef7121c679cf70e4a768f75d07982fc40364232..9d044fd182566b678c57580e308ccc9143b131a6 100644 (file)
@@ -420,6 +420,18 @@ static void *merge_core_dir_configs(apr_pool_t *a, void *basev, void *newv)
     return (void*)conf;
 }
 
+#if APR_HAS_SO_ACCEPTFILTER
+#ifndef ACCEPT_FILTER_NAME
+#define ACCEPT_FILTER_NAME "httpready"
+#ifdef __FreeBSD_version
+#if __FreeBSD_version < 411000 /* httpready broken before 4.1.1 */
+#undef ACCEPT_FILTER_NAME
+#define ACCEPT_FILTER_NAME "dataready"
+#endif
+#endif
+#endif
+#endif
+
 static void *create_core_server_config(apr_pool_t *a, server_rec *s)
 {
     core_server_config *conf;
@@ -427,41 +439,44 @@ static void *create_core_server_config(apr_pool_t *a, server_rec *s)
 
     conf = (core_server_config *)apr_pcalloc(a, sizeof(core_server_config));
 
-#ifdef GPROF
-    conf->gprof_dir = NULL;
+    /* global-default / global-only settings */
+
+    if (!is_virtual) {
+        conf->ap_document_root = DOCUMENT_LOCATION;
+        conf->access_name = DEFAULT_ACCESS_FNAME;
+
+        /* A mapping only makes sense in the global context */
+        conf->accf_map = apr_table_make(a, 5);
+#if APR_HAS_SO_ACCEPTFILTER
+        apr_table_setn(conf->accf_map, "http", ACCEPT_FILTER_NAME);
+        apr_table_setn(conf->accf_map, "https", "dataready");
+#else
+        apr_table_setn(conf->accf_map, "http", "data");
+        apr_table_setn(conf->accf_map, "https", "data");
 #endif
+    }
+    /* pcalloc'ed - we have NULL's/0's
+    else ** is_virtual ** {
+        conf->ap_document_root = NULL;
+        conf->access_name = NULL;
+        conf->accf_map = NULL;
+    }
+     */
+
+    /* initialization, no special case for global context */
 
-    conf->access_name = is_virtual ? NULL : DEFAULT_ACCESS_FNAME;
-    conf->ap_document_root = is_virtual ? NULL : DOCUMENT_LOCATION;
     conf->sec_dir = apr_array_make(a, 40, sizeof(ap_conf_vector_t *));
     conf->sec_url = apr_array_make(a, 40, sizeof(ap_conf_vector_t *));
 
-    /* recursion stopper */
-    conf->redirect_limit = 0; /* 0 == unset */
+    /* pcalloc'ed - we have NULL's/0's
+    conf->gprof_dir = NULL;
+
+    ** recursion stopper; 0 == unset
+    conf->redirect_limit = 0;
     conf->subreq_limit = 0;
 
     conf->protocol = NULL;
-    conf->accf_map = is_virtual ? NULL : apr_table_make(a, 5);
-
-    /* A mapping only makes sense in the global context */
-    if (conf->accf_map) {
-#if APR_HAS_SO_ACCEPTFILTER
-#ifndef ACCEPT_FILTER_NAME
-#define ACCEPT_FILTER_NAME "httpready"
-#ifdef __FreeBSD_version
-#if __FreeBSD_version < 411000 /* httpready broken before 4.1.1 */
-#undef ACCEPT_FILTER_NAME
-#define ACCEPT_FILTER_NAME "dataready"
-#endif
-#endif
-#endif
-    apr_table_setn(conf->accf_map, "http", ACCEPT_FILTER_NAME);
-    apr_table_setn(conf->accf_map, "https", "dataready");
-#else
-    apr_table_setn(conf->accf_map, "http", "data");
-    apr_table_setn(conf->accf_map, "https", "data");
-#endif
-    }
+     */
 
     conf->trace_enable = AP_TRACE_UNSET;
 
@@ -472,36 +487,35 @@ static void *merge_core_server_configs(apr_pool_t *p, void *basev, void *virtv)
 {
     core_server_config *base = (core_server_config *)basev;
     core_server_config *virt = (core_server_config *)virtv;
-    core_server_config *conf;
-
-    conf = (core_server_config *)apr_pmemdup(p, virt, sizeof(core_server_config));
-
-    if (!conf->access_name) {
-        conf->access_name = base->access_name;
-    }
+    core_server_config *conf = (core_server_config *)
+                               apr_pmemdup(p, base, sizeof(core_server_config));
 
-    if (!conf->ap_document_root) {
-        conf->ap_document_root = base->ap_document_root;
-    }
+    if (virt->ap_document_root)
+        conf->ap_document_root = virt->ap_document_root;
 
-    if (!conf->protocol) {
-        conf->protocol = base->protocol;
-    }
+    if (virt->access_name)
+        conf->access_name = virt->access_name;
 
+    /* XXX optimize to keep base->sec_ pointers if virt->sec_ array is empty */
     conf->sec_dir = apr_array_append(p, base->sec_dir, virt->sec_dir);
     conf->sec_url = apr_array_append(p, base->sec_url, virt->sec_url);
 
-    conf->redirect_limit = virt->redirect_limit
-                           ? virt->redirect_limit
-                           : base->redirect_limit;
+    if (virt->redirect_limit)
+        conf->redirect_limit = virt->redirect_limit;
+
+    if (virt->subreq_limit)
+        conf->subreq_limit = virt->subreq_limit;
+
+    if (virt->trace_enable != AP_TRACE_UNSET)
+        conf->trace_enable = virt->trace_enable;
+
+    /* no action for virt->accf_map, not allowed per-vhost */
 
-    conf->subreq_limit = virt->subreq_limit
-                         ? virt->subreq_limit
-                         : base->subreq_limit;
+    if (virt->protocol)
+        conf->protocol = virt->protocol;
 
-    conf->trace_enable = (virt->trace_enable != AP_TRACE_UNSET)
-                         ? virt->trace_enable
-                         : base->trace_enable;
+    if (virt->gprof_dir)
+        conf->gprof_dir = virt->gprof_dir;
 
     return conf;
 }