]>
Commit | Line | Data |
---|---|---|
63a80378 AM |
1 | commit 813fdb4c8e2fc02cf4c5738e46b204f28d0763a3 |
2 | Author: sf <sf@13f79535-47bb-0310-9956-ffa450edef68> | |
3 | Date: Sat Oct 2 14:44:20 2010 +0000 | |
4 | ||
5 | core: Speed up config parsing if using a very large number of config | |
6 | files | |
7 | ||
8 | PR: 50002 | |
9 | Submitted by: andrew cloudaccess net | |
10 | ||
11 | ||
12 | git-svn-id: http://svn.apache.org/repos/asf/httpd/httpd/trunk@1003808 13f79535-47bb-0310-9956-ffa450edef68 | |
13 | ||
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 | |
18 | @@ -156,7 +156,7 @@ | |
19 | #ifndef MODULE_MAGIC_NUMBER_MAJOR | |
20 | #define MODULE_MAGIC_NUMBER_MAJOR 20051115 | |
21 | #endif | |
22 | -#define MODULE_MAGIC_NUMBER_MINOR 31 /* 0...n */ | |
23 | +#define MODULE_MAGIC_NUMBER_MINOR 32 /* 0...n */ | |
24 | ||
25 | /** | |
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 { | |
32 | const char *filename; | |
33 | /** The line number the directive was on */ | |
34 | int line_num; | |
35 | + | |
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 | |
40 | + */ | |
41 | + struct ap_directive_t *last; | |
42 | }; | |
43 | ||
44 | /** | |
45 | diff --git a/server/config.c b/server/config.c | |
46 | index dc9b3b6..a3d67f0 100644 | |
47 | --- a/server/config.c | |
48 | +++ b/server/config.c | |
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); | |
52 | const char *errmsg; | |
53 | + ap_directive_t **last_ptr = NULL; | |
54 | + | |
55 | + if(current) { | |
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. | |
60 | + */ | |
61 | + last_ptr = &(current->last); | |
62 | + | |
63 | + if(last_ptr && *last_ptr) { | |
64 | + current = *last_ptr; | |
65 | + } | |
66 | + } | |
67 | ||
68 | if (current != NULL) { | |
69 | while (current->next) { | |
70 | current = current->next; | |
71 | } | |
72 | + | |
73 | + if(last_ptr) { | |
74 | + /* update cached pointer to last node */ | |
75 | + *last_ptr = current; | |
76 | + } | |
77 | } | |
78 | ||
79 | while (!(ap_cfg_getline(l, MAX_STRING_LEN, parms->config_file))) { |