1 commit 813fdb4c8e2fc02cf4c5738e46b204f28d0763a3
2 Author: sf <sf@13f79535-47bb-0310-9956-ffa450edef68>
3 Date: Sat Oct 2 14:44:20 2010 +0000
5 core: Speed up config parsing if using a very large number of config
9 Submitted by: andrew cloudaccess net
12 git-svn-id: http://svn.apache.org/repos/asf/httpd/httpd/trunk@1003808 13f79535-47bb-0310-9956-ffa450edef68
14 diff --git a/include/ap_mmn.h b/include/ap_mmn.h
15 index f44a22b..5207637 100644
16 --- a/include/ap_mmn.h
17 +++ b/include/ap_mmn.h
19 #ifndef MODULE_MAGIC_NUMBER_MAJOR
20 #define MODULE_MAGIC_NUMBER_MAJOR 20051115
22 -#define MODULE_MAGIC_NUMBER_MINOR 31 /* 0...n */
23 +#define MODULE_MAGIC_NUMBER_MINOR 32 /* 0...n */
26 * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
27 diff --git a/include/util_cfgtree.h b/include/util_cfgtree.h
28 index 4da4c7d..791a5cc 100644
29 --- a/include/util_cfgtree.h
30 +++ b/include/util_cfgtree.h
31 @@ -64,6 +64,13 @@ struct ap_directive_t {
33 /** The line number the directive was on */
36 + /** A short-cut towards the last directive node in the tree.
37 + * The value may not always be up-to-date but it always points to
38 + * somewhere in the tree, nearer to the tail.
39 + * This value is only set in the first node
41 + struct ap_directive_t *last;
45 diff --git a/server/config.c b/server/config.c
46 index dc9b3b6..a3d67f0 100644
49 @@ -1284,11 +1284,30 @@ AP_DECLARE(const char *) ap_build_config(cmd_parms *parms,
50 ap_directive_t *curr_parent = NULL;
51 char *l = apr_palloc (temp_pool, MAX_STRING_LEN);
53 + ap_directive_t **last_ptr = NULL;
56 + /* If we have to traverse the whole tree again for every included
57 + * config file, the required time grows as O(n^2) with the number of
58 + * files. This can be a significant delay for large configurations.
59 + * Therefore we cache a pointer to the last node.
61 + last_ptr = &(current->last);
63 + if(last_ptr && *last_ptr) {
64 + current = *last_ptr;
68 if (current != NULL) {
69 while (current->next) {
70 current = current->next;
74 + /* update cached pointer to last node */
75 + *last_ptr = current;
79 while (!(ap_cfg_getline(l, MAX_STRING_LEN, parms->config_file))) {