httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rpl...@apache.org
Subject svn commit: r328466 - in /httpd/httpd/branches/2.2.x: CHANGES modules/cache/mod_cache.c
Date Tue, 25 Oct 2005 20:10:51 GMT
Author: rpluem
Date: Tue Oct 25 13:10:43 2005
New Revision: 328466

URL: http://svn.apache.org/viewcvs?rev=328466&view=rev
Log:
Merge r325960 from trunk:

* Create new filters CACHE_OUT_SUBREQ / CACHE_SAVE_SUBREQ which only differ
  by the type (AP_FTYPE_CONTENT_SET-1) from CACHE_OUT / CACHE_SAVE
  (AP_FTYPE_CONTENT_SET+1). This ensures that subrequests to non local
  resources do not get stuck in the middle of the road with the contents
  only written to the temp file, because CACHE_OUT_SUBREQ / CACHE_SAVE_SUBREQ
  are inserted *before* the SUBREQ_CORE filter in the filter chain.

Modified:
    httpd/httpd/branches/2.2.x/CHANGES
    httpd/httpd/branches/2.2.x/modules/cache/mod_cache.c

Modified: httpd/httpd/branches/2.2.x/CHANGES
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.2.x/CHANGES?rev=328466&r1=328465&r2=328466&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/CHANGES [utf-8] (original)
+++ httpd/httpd/branches/2.2.x/CHANGES [utf-8] Tue Oct 25 13:10:43 2005
@@ -1,6 +1,10 @@
                                                         -*- coding: utf-8 -*-
 Changes with Apache 2.1.9
 
+  *) mod_cache: Create new filters CACHE_OUT_SUBREQ / CACHE_SAVE_SUBREQ which
+     only differ by the type from CACHE_OUT / CACHE_SAVE to ensure that
+     subrequests to non local resources work again. [Ruediger Pluem]
+
   *) mod_proxy: Do not lowercase the entire worker name of a BalancerMember
      since this breaks case sensitive URI's. PR36906.  [Ruediger Pluem]
 

Modified: httpd/httpd/branches/2.2.x/modules/cache/mod_cache.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.2.x/modules/cache/mod_cache.c?rev=328466&r1=328465&r2=328466&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/cache/mod_cache.c (original)
+++ httpd/httpd/branches/2.2.x/modules/cache/mod_cache.c Tue Oct 25 13:10:43 2005
@@ -28,7 +28,9 @@
  * a name-to-function mapping on each request
  */
 static ap_filter_rec_t *cache_save_filter_handle;
+static ap_filter_rec_t *cache_save_subreq_filter_handle;
 static ap_filter_rec_t *cache_out_filter_handle;
+static ap_filter_rec_t *cache_out_subreq_filter_handle;
 static ap_filter_rec_t *cache_remove_url_filter_handle;
 
 /*
@@ -109,12 +111,27 @@
     if (rv != OK) {
         if (rv == DECLINED) {
             if (!lookup) {
-                ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server,
-                  "Adding CACHE_SAVE filter for %s", r->uri);
 
-                /* add cache_save filter to cache this request */
-                ap_add_output_filter_handle(cache_save_filter_handle, NULL, r,
-                                            r->connection);
+                /*
+                 * 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", 
@@ -189,8 +206,20 @@
      * filters have been set. So lets run the insert_filter hook.
      */
     ap_run_insert_filter(r);
-    ap_add_output_filter_handle(cache_out_filter_handle, NULL,
-                                r, r->connection);
+
+    /*
+     * Add cache_out filter to serve this request. Choose
+     * the correct filter by checking if we are a subrequest
+     * or not.
+     */
+    if (r->main) {
+        ap_add_output_filter_handle(cache_out_subreq_filter_handle, NULL,
+                                    r, r->connection);
+    }
+    else {
+        ap_add_output_filter_handle(cache_out_filter_handle, NULL,
+                                    r, r->connection);
+    }
 
     /* kick off the filter stack */
     out = apr_brigade_create(r->pool, r->connection->bucket_alloc);
@@ -1146,23 +1175,56 @@
     /* cache filters 
      * XXX The cache filters need to run right after the handlers and before
      * any other filters. Consider creating AP_FTYPE_CACHE for this purpose.
-     * Make them AP_FTYPE_CONTENT for now.
-     * XXX ianhH:they should run AFTER all the other content filters.
+     *
+     * Depending on the type of request (subrequest / main request) they
+     * need to be run before AP_FTYPE_CONTENT_SET / after AP_FTYPE_CONTENT_SET
+     * filters. Thus create two filter handles for each type:
+     * cache_save_filter_handle / cache_out_filter_handle to be used by
+     * main requests and
+     * cache_save_subreq_filter_handle / cache_out_subreq_filter_handle
+     * to be run by subrequest
+     */
+    /*
+     * CACHE_SAVE must go into the filter chain after a possible DEFLATE
+     * filter to ensure that the compressed content is stored.
+     * Incrementing filter type by 1 ensures his happens.
      */
     cache_save_filter_handle = 
         ap_register_output_filter("CACHE_SAVE", 
                                   cache_save_filter, 
                                   NULL,
                                   AP_FTYPE_CONTENT_SET+1);
-    /* CACHE_OUT must go into the filter chain before SUBREQ_CORE to
-     * handle subrequsts. Decrementing filter type by 1 ensures this 
+    /*
+     * CACHE_SAVE_SUBREQ must go into the filter chain before SUBREQ_CORE to
+     * handle subrequsts. Decrementing filter type by 1 ensures this
      * happens.
      */
+    cache_save_subreq_filter_handle =
+        ap_register_output_filter("CACHE_SAVE_SUBREQ",
+                                  cache_save_filter,
+                                  NULL,
+                                  AP_FTYPE_CONTENT_SET-1);
+    /*
+     * CACHE_OUT must go into the filter chain after a possible DEFLATE
+     * filter to ensure that already compressed cache objects do not
+     * get compressed again. Incrementing filter type by 1 ensures
+     * his happens.
+     */
     cache_out_filter_handle = 
         ap_register_output_filter("CACHE_OUT", 
                                   cache_out_filter, 
                                   NULL,
                                   AP_FTYPE_CONTENT_SET+1);
+    /*
+     * CACHE_OUT_SUBREQ must go into the filter chain before SUBREQ_CORE to
+     * handle subrequsts. Decrementing filter type by 1 ensures this
+     * happens.
+     */
+    cache_out_subreq_filter_handle =
+        ap_register_output_filter("CACHE_OUT_SUBREQ",
+                                  cache_out_filter,
+                                  NULL,
+                                  AP_FTYPE_CONTENT_SET-1);
     /* CACHE_REMOVE_URL has to be a protocol filter to ensure that is
      * run even if the response is a canned error message, which
      * removes the content filters.



Mime
View raw message