httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s.@apache.org
Subject svn commit: r1003808 - in /httpd/httpd/trunk: CHANGES include/ap_mmn.h include/util_cfgtree.h server/config.c
Date Sat, 02 Oct 2010 14:44:21 GMT
Author: sf
Date: Sat Oct  2 14:44:20 2010
New Revision: 1003808

URL: http://svn.apache.org/viewvc?rev=1003808&view=rev
Log:
core: Speed up config parsing if using a very large number of config
files

PR: 50002
Submitted by: andrew cloudaccess net

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/include/ap_mmn.h
    httpd/httpd/trunk/include/util_cfgtree.h
    httpd/httpd/trunk/server/config.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1003808&r1=1003807&r2=1003808&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Sat Oct  2 14:44:20 2010
@@ -6,6 +6,9 @@ Changes with Apache 2.3.9
      Fix a denial of service attack against mod_reqtimeout.
      [Stefan Fritsch]
 
+  *) core: Speed up config parsing if using a very large number of config
+     files. PR 50002 [andrew cloudaccess net]
+
   *) mod_cache: Support the caching of HEAD requests. [Graham Leggett]
 
   *) htcacheclean: Allow the option to round up file sizes to a given

Modified: httpd/httpd/trunk/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=1003808&r1=1003807&r2=1003808&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_mmn.h (original)
+++ httpd/httpd/trunk/include/ap_mmn.h Sat Oct  2 14:44:20 2010
@@ -272,6 +272,7 @@
  * 20100923.1 (2.3.9-dev)  Add cache_status hook.
  * 20100923.2 (2.3.9-dev)  Add generate_log_id hook.
  *                         Make root parameter of ap_expr_eval() const.
+ * 20100923.3 (2.3.9-dev)  Add "last" member to ap_directive_t
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
@@ -279,7 +280,7 @@
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20100923
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 2                     /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 3                     /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a

Modified: httpd/httpd/trunk/include/util_cfgtree.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/util_cfgtree.h?rev=1003808&r1=1003807&r2=1003808&view=diff
==============================================================================
--- httpd/httpd/trunk/include/util_cfgtree.h (original)
+++ httpd/httpd/trunk/include/util_cfgtree.h Sat Oct  2 14:44:20 2010
@@ -64,6 +64,13 @@ struct ap_directive_t {
     const char *filename;
     /** The line number the directive was on */
     int line_num;
+
+    /** A short-cut towards the last directive node in the tree.
+     *  The value may not always be up-to-date but it always points to
+     *  somewhere in the tree, nearer to the tail.
+     *  This value is only set in the first node
+     */
+    struct ap_directive_t *last;
 };
 
 /**

Modified: httpd/httpd/trunk/server/config.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/config.c?rev=1003808&r1=1003807&r2=1003808&view=diff
==============================================================================
--- httpd/httpd/trunk/server/config.c (original)
+++ httpd/httpd/trunk/server/config.c Sat Oct  2 14:44:20 2010
@@ -1284,11 +1284,30 @@ AP_DECLARE(const char *) ap_build_config
     ap_directive_t *curr_parent = NULL;
     char *l = apr_palloc (temp_pool, MAX_STRING_LEN);
     const char *errmsg;
+    ap_directive_t **last_ptr = NULL;
+
+    if(current) {
+        /* If we have to traverse the whole tree again for every included
+         * config file, the required time grows as O(n^2) with the number of
+         * files. This can be a significant delay for large configurations.
+         * Therefore we cache a pointer to the last node.
+         */
+        last_ptr = &(current->last);
+
+        if(last_ptr && *last_ptr) {
+            current = *last_ptr;
+        }
+    }
 
     if (current != NULL) {
         while (current->next) {
             current = current->next;
         }
+
+        if(last_ptr) {
+            /* update cached pointer to last node */
+            *last_ptr = current;
+        }
     }
 
     while (!(ap_cfg_getline(l, MAX_STRING_LEN, parms->config_file))) {



Mime
View raw message