httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Davi Arnaut <d...@haxent.com.br>
Subject [patch 04/16] shrink cache_url_handler
Date Wed, 20 Sep 2006 02:33:57 GMT
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) {

--

Mime
View raw message