You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by sf...@apache.org on 2011/01/18 10:58:27 UTC
svn commit: r1060283 - in /httpd/httpd/trunk: include/ap_mmn.h
include/http_core.h server/core.c server/request.c
Author: sf
Date: Tue Jan 18 09:58:26 2011
New Revision: 1060283
URL: http://svn.apache.org/viewvc?rev=1060283&view=rev
Log:
Initialize the core_dir_config->sec_files and ->sec_if only if needed.
This saves some memory and two apr_array_append()s per directory merge.
Modified:
httpd/httpd/trunk/include/ap_mmn.h
httpd/httpd/trunk/include/http_core.h
httpd/httpd/trunk/server/core.c
httpd/httpd/trunk/server/request.c
Modified: httpd/httpd/trunk/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=1060283&r1=1060282&r2=1060283&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_mmn.h (original)
+++ httpd/httpd/trunk/include/ap_mmn.h Tue Jan 18 09:58:26 2011
@@ -295,7 +295,8 @@
* dynamic growth of balancer members; Remove
* BalancerNonce in favor of 'nonce' parameter.
* 20110117.0 (2.3.11-dev) Merge <If> sections in separate step (ap_if_walk).
- * Add core_dir_config->sec_if.
+ * Add core_dir_config->sec_if. Add ap_add_if_conf().
+ * Add pool argument to ap_add_file_conf().
*/
#define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
Modified: httpd/httpd/trunk/include/http_core.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/http_core.h?rev=1060283&r1=1060282&r2=1060283&view=diff
==============================================================================
--- httpd/httpd/trunk/include/http_core.h (original)
+++ httpd/httpd/trunk/include/http_core.h Tue Jan 18 09:58:26 2011
@@ -598,8 +598,8 @@ void ap_core_reorder_directories(apr_poo
/* for mod_perl */
AP_CORE_DECLARE(void) ap_add_per_dir_conf(server_rec *s, void *dir_config);
AP_CORE_DECLARE(void) ap_add_per_url_conf(server_rec *s, void *url_config);
-AP_CORE_DECLARE(void) ap_add_file_conf(core_dir_config *conf, void *url_config);
-AP_CORE_DECLARE(void) ap_add_if_conf(core_dir_config *conf, void *url_config);
+AP_CORE_DECLARE(void) ap_add_file_conf(apr_pool_t *p, core_dir_config *conf, void *url_config);
+AP_CORE_DECLARE(void) ap_add_if_conf(apr_pool_t *p, core_dir_config *conf, void *url_config);
AP_CORE_DECLARE_NONSTD(const char *) ap_limit_section(cmd_parms *cmd, void *dummy, const char *arg);
/* Core filters; not exported. */
Modified: httpd/httpd/trunk/server/core.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/core.c?rev=1060283&r1=1060282&r2=1060283&view=diff
==============================================================================
--- httpd/httpd/trunk/server/core.c (original)
+++ httpd/httpd/trunk/server/core.c Tue Jan 18 09:58:26 2011
@@ -135,12 +135,12 @@ static void *create_core_dir_config(apr_
* conf->limit_cpu = NULL;
* conf->limit_mem = NULL;
* conf->limit_nproc = NULL;
+ * conf->sec_file = NULL;
+ * conf->sec_if = NULL;
*/
conf->limit_req_body = AP_LIMIT_REQ_BODY_UNSET;
conf->limit_xml_body = AP_LIMIT_UNSET;
- conf->sec_file = apr_array_make(a, 2, sizeof(ap_conf_vector_t *));
- conf->sec_if = apr_array_make(a, 2, sizeof(ap_conf_vector_t *));
conf->server_signature = srv_sig_unset;
@@ -513,17 +513,27 @@ AP_CORE_DECLARE(void) ap_add_per_url_con
*new_space = url_config;
}
-AP_CORE_DECLARE(void) ap_add_file_conf(core_dir_config *conf, void *url_config)
+AP_CORE_DECLARE(void) ap_add_file_conf(apr_pool_t *p, core_dir_config *conf,
+ void *url_config)
{
- void **new_space = (void **)apr_array_push(conf->sec_file);
+ void **new_space;
+ if (!conf->sec_file)
+ conf->sec_file = apr_array_make(p, 2, sizeof(ap_conf_vector_t *));
+
+ new_space = (void **)apr_array_push(conf->sec_file);
*new_space = url_config;
}
-AP_CORE_DECLARE(void) ap_add_if_conf(core_dir_config *conf, void *url_config)
+AP_CORE_DECLARE(void) ap_add_if_conf(apr_pool_t *p, core_dir_config *conf,
+ void *url_config)
{
- void **new_space = (void **)apr_array_push(conf->sec_if);
+ void **new_space;
+
+ if (!conf->sec_if)
+ conf->sec_if = apr_array_make(p, 2, sizeof(ap_conf_vector_t *));
+ new_space = (void **)apr_array_push(conf->sec_if);
*new_space = url_config;
}
@@ -2032,7 +2042,7 @@ static const char *filesection(cmd_parms
conf->d_is_fnmatch = apr_fnmatch_test(conf->d) != 0;
conf->r = r;
- ap_add_file_conf((core_dir_config *)mconfig, new_file_conf);
+ ap_add_file_conf(cmd->pool, (core_dir_config *)mconfig, new_file_conf);
if (*arg != '\0') {
return apr_pstrcat(cmd->pool, "Multiple ", thiscmd->name,
@@ -2095,7 +2105,7 @@ static const char *ifsection(cmd_parms *
conf->d_is_fnmatch = 0;
conf->r = NULL;
- ap_add_if_conf((core_dir_config *)mconfig, new_file_conf);
+ ap_add_if_conf(cmd->pool, (core_dir_config *)mconfig, new_file_conf);
if (*arg != '\0') {
return apr_pstrcat(cmd->pool, "Multiple ", thiscmd->name,
Modified: httpd/httpd/trunk/server/request.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/request.c?rev=1060283&r1=1060282&r2=1060283&view=diff
==============================================================================
--- httpd/httpd/trunk/server/request.c (original)
+++ httpd/httpd/trunk/server/request.c Tue Jan 18 09:58:26 2011
@@ -1459,12 +1459,17 @@ AP_DECLARE(int) ap_file_walk(request_rec
ap_conf_vector_t *now_merged = NULL;
core_dir_config *dconf = ap_get_module_config(r->per_dir_config,
&core_module);
- ap_conf_vector_t **sec_ent = (ap_conf_vector_t **)dconf->sec_file->elts;
- int num_sec = dconf->sec_file->nelts;
+ ap_conf_vector_t **sec_ent = NULL;
+ int num_sec = 0;
walk_cache_t *cache;
const char *test_file;
int cached;
+ if (dconf->sec_file) {
+ sec_ent = (ap_conf_vector_t **)dconf->sec_file->elts;
+ num_sec = dconf->sec_file->nelts;
+ }
+
/* To allow broken modules to proceed, we allow missing filenames to pass.
* We will catch it later if it's heading for the core handler.
* directory_walk already posted an INFO note for module debugging.
@@ -1616,8 +1621,8 @@ AP_DECLARE(int) ap_if_walk(request_rec *
ap_conf_vector_t *now_merged = NULL;
core_dir_config *dconf = ap_get_module_config(r->per_dir_config,
&core_module);
- ap_conf_vector_t **sec_ent = (ap_conf_vector_t **)dconf->sec_if->elts;
- int num_sec = dconf->sec_if->nelts;
+ ap_conf_vector_t **sec_ent = NULL;
+ int num_sec = 0;
walk_cache_t *cache;
int cached;
int sec_idx;
@@ -1625,6 +1630,11 @@ AP_DECLARE(int) ap_if_walk(request_rec *
int cached_matches;
walk_walked_t *last_walk;
+ if (dconf->sec_if) {
+ sec_ent = (ap_conf_vector_t **)dconf->sec_if->elts;
+ num_sec = dconf->sec_if->nelts;
+ }
+
/* No tricks here, there are just no <If > to parse in this context.
* We won't destroy the cache, just in case _this_ redirect is later
* redirected again to a context containing the same or similar <If >.