Return-Path: Delivered-To: apmail-httpd-dev-archive@www.apache.org Received: (qmail 55451 invoked from network); 20 Sep 2006 02:34:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 20 Sep 2006 02:34:35 -0000 Received: (qmail 28289 invoked by uid 500); 20 Sep 2006 02:34:18 -0000 Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 28131 invoked by uid 500); 20 Sep 2006 02:34:18 -0000 Mailing-List: contact dev-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@httpd.apache.org Received: (qmail 28108 invoked by uid 99); 20 Sep 2006 02:34:17 -0000 Received: from idunn.apache.osuosl.org (HELO idunn.apache.osuosl.org) (140.211.166.84) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Sep 2006 19:34:17 -0700 X-ASF-Spam-Status: No, hits=0.1 required=5.0 tests=FORGED_RCVD_HELO Received: from ([65.99.219.155:2674] helo=haxent.com) by idunn.apache.osuosl.org (ecelerity 2.1 r(10620)) with ESMTP id 47/13-00639-5A8A0154 for ; Tue, 19 Sep 2006 19:34:14 -0700 Received: from montefiori.dyndns.org (unknown [201.21.156.184]) by haxent.com (Postfix) with ESMTP id 2625B274AB for ; Tue, 19 Sep 2006 23:34:09 -0300 (BRT) Received: by montefiori.dyndns.org (Postfix, from userid 500) id 0C8A61090B8; Tue, 19 Sep 2006 23:34:40 -0300 (BRT) Message-Id: <20060920023439.540984000@haxent.com.br> References: <20060920023353.514118000@haxent.com.br> User-Agent: quilt/0.45-1 Date: Tue, 19 Sep 2006 23:33:57 -0300 From: Davi Arnaut To: dev@httpd.apache.org Subject: [patch 04/16] shrink cache_url_handler Content-Disposition: inline; filename=004.patch X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Move parts of cache_url_handler() to a smaller add_cache_filters() function that is easier to read and understand. Index: modules/cache/mod_cache.c =================================================================== --- modules/cache/mod_cache.c.orig +++ modules/cache/mod_cache.c @@ -48,6 +48,44 @@ * oh well. */ +static void add_cache_filters(request_rec *r, cache_request_rec *cache) +{ + /* + * Add cache_save filter to cache this request. Choose + * the correct filter by checking if we are a subrequest + * or not. + */ + if (r->main) { + ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, + r->server, + "Adding CACHE_SAVE_SUBREQ filter for %s", + r->uri); + ap_add_output_filter_handle(cache_save_subreq_filter_handle, + NULL, r, r->connection); + } + else { + ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, + r->server, "Adding CACHE_SAVE filter for %s", + r->uri); + ap_add_output_filter_handle(cache_save_filter_handle, + NULL, r, r->connection); + } + + ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server, + "Adding CACHE_REMOVE_URL filter for %s", + r->uri); + + /* Add cache_remove_url filter to this request to remove a + * stale cache entry if needed. Also put the current cache + * request rec in the filter context, as the request that + * is available later during running the filter maybe + * different due to an internal redirect. + */ + cache->remove_url_filter = + ap_add_output_filter_handle(cache_remove_url_filter_handle, + cache, r, r->connection); +} + static int cache_url_handler(request_rec *r, int lookup) { apr_status_t rv; @@ -113,41 +151,7 @@ if (rv != OK) { if (rv == DECLINED) { if (!lookup) { - - /* - * Add cache_save filter to cache this request. Choose - * the correct filter by checking if we are a subrequest - * or not. - */ - if (r->main) { - ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, - r->server, - "Adding CACHE_SAVE_SUBREQ filter for %s", - r->uri); - ap_add_output_filter_handle(cache_save_subreq_filter_handle, - NULL, r, r->connection); - } - else { - ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, - r->server, "Adding CACHE_SAVE filter for %s", - r->uri); - ap_add_output_filter_handle(cache_save_filter_handle, - NULL, r, r->connection); - } - - ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server, - "Adding CACHE_REMOVE_URL filter for %s", - r->uri); - - /* Add cache_remove_url filter to this request to remove a - * stale cache entry if needed. Also put the current cache - * request rec in the filter context, as the request that - * is available later during running the filter maybe - * different due to an internal redirect. - */ - cache->remove_url_filter = - ap_add_output_filter_handle(cache_remove_url_filter_handle, - cache, r, r->connection); + add_cache_filters(r, cache); } else { if (cache->stale_headers) { --