Return-Path: Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 70547 invoked by uid 500); 28 Sep 2001 18:57:31 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 70534 invoked by uid 500); 28 Sep 2001 18:57:30 -0000 Delivered-To: apmail-httpd-2.0-cvs@apache.org Date: 28 Sep 2001 18:56:21 -0000 Message-ID: <20010928185621.80778.qmail@icarus.apache.org> From: wrowe@apache.org To: httpd-2.0-cvs@apache.org Subject: cvs commit: httpd-2.0/server request.c X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N wrowe 01/09/28 11:56:21 Modified: server request.c Log: Split out (soon to be) common code for all _walk functions (no net change to location_walk). Revision Changes Path 1.55 +58 -38 httpd-2.0/server/request.c Index: request.c =================================================================== RCS file: /home/cvs/httpd-2.0/server/request.c,v retrieving revision 1.54 retrieving revision 1.55 diff -u -r1.54 -r1.55 --- request.c 2001/09/28 04:46:37 1.54 +++ request.c 2001/09/28 18:56:21 1.55 @@ -275,6 +275,63 @@ } +/* Useful caching structures to repeat _walk/merge sequences as required + * when a subrequest or redirect reuses substantially the same config. + * + * Directive order in the httpd.conf file and its Includes significantly + * impact this optimization. Grouping common blocks at the front of the + * config that are less likely to change between a request and + * its subrequests, or between a request and its redirects reduced + * the work of these functions significantly. + */ + + typedef struct walk_walked_t { + ap_conf_vector_t *matched; /* A dir_conf sections we matched */ + ap_conf_vector_t *merged; /* The dir_conf merged result */ +} walk_walked_t; + +typedef struct walk_cache_t { + const char *cached; /* The identifier we matched */ + ap_conf_vector_t **dir_conf_tested;/* The sections we matched against */ + ap_conf_vector_t *per_dir_result; /* per_dir_config += walked result */ + apr_array_header_t *walked; /* The list of walk_walked_t results */ +} walk_cache_t; + +static walk_cache_t *prep_walk_cache(const char *cache_name, request_rec *r) +{ + walk_cache_t *cache; + + /* Find the most relevant, recent entry to work from. That would be + * this request (on the second call), or the parent request of a + * subrequest, or the prior request of an internal redirect. Provide + * this _walk()er with a copy it is allowed to munge. If there is no + * parent or prior cached request, then create a new walk cache. + */ + if ((apr_pool_userdata_get((void **)&cache, + cache_name, r->pool) + != APR_SUCCESS) || !cache) + { + if ((r->main && (apr_pool_userdata_get((void **)&cache, + cache_name, + r->main->pool) + == APR_SUCCESS) && cache) + || (r->prev && (apr_pool_userdata_get((void **)&cache, + cache_name, + r->prev->pool) + == APR_SUCCESS) && cache)) { + cache = apr_pmemdup(r->pool, cache, sizeof(*cache)); + cache->walked = apr_array_copy(r->pool, cache->walked); + } + else { + cache = apr_pcalloc(r->pool, sizeof(*cache)); + cache->walked = apr_array_make(r->pool, 4, sizeof(walk_walked_t)); + } + apr_pool_userdata_set(cache, cache_name, + apr_pool_cleanup_null, r->pool); + } + return cache; +} + /***************************************************************** * * Getting and checking directory configuration. Also checks the @@ -1126,18 +1183,6 @@ #endif /* defined REPLACE_PATH_INFO_METHOD */ -typedef struct walk_walked_t { - ap_conf_vector_t *matched; /* A dir_conf sections we matched */ - ap_conf_vector_t *merged; /* The dir_conf merged result */ -} walk_walked_t; - -typedef struct walk_cache_t { - const char *cached; /* The identifier we matched */ - ap_conf_vector_t **dir_conf_tested;/* The sections we matched against */ - ap_conf_vector_t *per_dir_result; /* per_dir_config += walked result */ - apr_array_header_t *walked; /* The list of walk_walked_t results */ -} walk_cache_t; - AP_DECLARE(int) ap_location_walk(request_rec *r) { ap_conf_vector_t *now_merged = NULL; @@ -1151,32 +1196,7 @@ const char *entry_uri; int len, j; - /* Find the most relevant, recent entry to work from. That would be - * this request (on the second call), or the parent request of a - * subrequest, or the prior request of an internal redirect. - */ - if ((apr_pool_userdata_get((void **)&cache, - "ap_location_walk::cache", r->pool) - != APR_SUCCESS) || !cache) - { - if ((r->main && (apr_pool_userdata_get((void **)&cache, - "ap_location_walk::cache", - r->main->pool) - == APR_SUCCESS) && cache) - || (r->prev && (apr_pool_userdata_get((void **)&cache, - "ap_location_walk::cache", - r->prev->pool) - == APR_SUCCESS) && cache)) { - cache = apr_pmemdup(r->pool, cache, sizeof(*cache)); - cache->walked = apr_array_copy(r->pool, cache->walked); - } - else { - cache = apr_pcalloc(r->pool, sizeof(*cache)); - cache->walked = apr_array_make(r->pool, 4, sizeof(walk_walked_t)); - } - apr_pool_userdata_set(cache, "ap_location_walk::cache", - apr_pool_cleanup_null, r->pool); - } + cache = prep_walk_cache("ap_location_walk::cache", r); /* No tricks here, there are no to parse in this vhost. * We won't destroy the cache, just in case _this_ redirect is later