You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by wr...@apache.org on 2009/01/03 20:17:15 UTC

svn commit: r731067 - /httpd/httpd/trunk/server/core.c

Author: wrowe
Date: Sat Jan  3 11:17:14 2009
New Revision: 731067

URL: http://svn.apache.org/viewvc?rev=731067&view=rev
Log:

Reorder and correct creation and merge of server records, optimizing
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.

Modified:
    httpd/httpd/trunk/server/core.c

Modified: httpd/httpd/trunk/server/core.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/core.c?rev=731067&r1=731066&r2=731067&view=diff
==============================================================================
--- httpd/httpd/trunk/server/core.c (original)
+++ httpd/httpd/trunk/server/core.c Sat Jan  3 11:17:14 2009
@@ -420,6 +420,18 @@
     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 @@
 
     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 @@
 {
     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));
+    core_server_config *conf = (core_server_config *)
+                               apr_pmemdup(p, base, sizeof(core_server_config));
 
-    if (!conf->access_name) {
-        conf->access_name = base->access_name;
-    }
-
-    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;
-
-    conf->subreq_limit = virt->subreq_limit
-                         ? virt->subreq_limit
-                         : base->subreq_limit;
-
-    conf->trace_enable = (virt->trace_enable != AP_TRACE_UNSET)
-                         ? virt->trace_enable
-                         : base->trace_enable;
+    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 */
+
+    if (virt->protocol)
+        conf->protocol = virt->protocol;
+
+    if (virt->gprof_dir)
+        conf->gprof_dir = virt->gprof_dir;
 
     return conf;
 }