You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rp...@apache.org on 2006/01/05 14:47:01 UTC

svn commit: r366181 - in /httpd/httpd/trunk/modules: http/chunk_filter.c proxy/proxy_util.c

Author: rpluem
Date: Thu Jan  5 05:46:57 2006
New Revision: 366181

URL: http://svn.apache.org/viewcvs?rev=366181&view=rev
Log:
* If a subrequest has a broken backend also set no_cache for the main request
  and ensure that the chunk filter does not sent the last chunk marker in this
  case.

  modules/http/chunk_filter.c: Memorize HTTP_BAD_GATEWAY error buckets that
                               had been seen in filter context to ensure
                               that we do not sent the last chunk marker in
                               this case.
  modules/proxy/proxy_util.c : Set no_cache also for main request if we are
                               a subrequest.

  Thanks to Joe Orton and André Malo for the "invented unique pointer" trick.

Modified:
    httpd/httpd/trunk/modules/http/chunk_filter.c
    httpd/httpd/trunk/modules/proxy/proxy_util.c

Modified: httpd/httpd/trunk/modules/http/chunk_filter.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/modules/http/chunk_filter.c?rev=366181&r1=366180&r2=366181&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http/chunk_filter.c (original)
+++ httpd/httpd/trunk/modules/http/chunk_filter.c Thu Jan  5 05:46:57 2006
@@ -39,6 +39,12 @@
 
 #include "mod_core.h"
 
+/*
+ * A pointer to this is used to memorize in the filter context that a bad
+ * gateway error bucket had been seen. It is used as an invented unique pointer.
+ */
+static char bad_gateway_seen;
+
 apr_status_t ap_http_chunk_filter(ap_filter_t *f, apr_bucket_brigade *b)
 {
 #define ASCII_CRLF  "\015\012"
@@ -47,7 +53,6 @@
     apr_bucket_brigade *more;
     apr_bucket *e;
     apr_status_t rv;
-    int bad_gateway_seen = 0;
 
     for (more = NULL; b; b = more, more = NULL) {
         apr_off_t bytes = 0;
@@ -71,8 +76,11 @@
             if (AP_BUCKET_IS_ERROR(e)
                 && (((ap_bucket_error *)(e->data))->status
                     == HTTP_BAD_GATEWAY)) {
-                /* We had a broken backend. Memorize this. */
-                bad_gateway_seen = 1;
+                /*
+                 * We had a broken backend. Memorize this in the filter
+                 * context.
+                 */
+                f->ctx = &bad_gateway_seen;
                 continue;
             }
             if (APR_BUCKET_IS_FLUSH(e)) {
@@ -155,7 +163,8 @@
          *   3) the end-of-chunked body CRLF
          *
          * If there is no EOS bucket, or if we had seen an error bucket with
-         * status HTTP_BAD_GATEWAY then do nothing.
+         * status HTTP_BAD_GATEWAY then do nothing. We have memorized an
+         * error bucket that we had seen in the filter context.
          * The error bucket with status HTTP_BAD_GATEWAY indicates that the
          * connection to the backend (mod_proxy) broke in the middle of the
          * response. In order to signal the client that something went wrong
@@ -166,7 +175,7 @@
          * marker above, but this is a bit more straight-forward for
          * now.
          */
-        if (eos && !bad_gateway_seen) {
+        if (eos && !f->ctx) {
             /* XXX: (2) trailers ... does not yet exist */
             e = apr_bucket_immortal_create(ASCII_ZERO ASCII_CRLF
                                            /* <trailers> */

Modified: httpd/httpd/trunk/modules/proxy/proxy_util.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/modules/proxy/proxy_util.c?rev=366181&r1=366180&r2=366181&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/proxy_util.c (original)
+++ httpd/httpd/trunk/modules/proxy/proxy_util.c Thu Jan  5 05:46:57 2006
@@ -2137,6 +2137,12 @@
     conn_rec *c = r->connection;
 
     r->no_cache = 1;
+    /*
+     * If this is a subrequest, then prevent also caching of the main
+     * request.
+     */
+    if (r->main)
+        r->main->no_cache = 1;
     e = ap_bucket_error_create(HTTP_BAD_GATEWAY, NULL, c->pool,
                                c->bucket_alloc);
     APR_BRIGADE_INSERT_TAIL(brigade, e);