]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mod_mem_cache: Don't cache incomplete responses when the client
authorYann Ylavic <ylavic@apache.org>
Tue, 16 Aug 2016 23:36:51 +0000 (23:36 +0000)
committerYann Ylavic <ylavic@apache.org>
Tue, 16 Aug 2016 23:36:51 +0000 (23:36 +0000)
connection is aborted before the body is fully read.  PR 45049.

Backports: n/a (2.2.x only)
Submitted by: Nick Pace <nick simplylogic.net>, Edward Lu, Yann Ylavic
Reviewed by: ylavic, wrowe, rpluem

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@1756565 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/cache/mod_mem_cache.c

diff --git a/CHANGES b/CHANGES
index cd1f8f60bb813a8d2fa3362ac334663f82904aaa..5154da648346c11c16c63b12a77f1870683c0f7e 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -28,6 +28,10 @@ Changes with Apache 2.2.32
      SubstituteInheritBefore on|off directive.  PR 57641
      [Marc.Stern <Marc.Stern approach.be>, Yann Ylavic, William Rowe]
 
+  *) mod_mem_cache: Don't cache incomplete responses when the client
+     connection is aborted before the body is fully read.  PR 45049.
+     [Nick Pace <nick simplylogic.net>, Edward Lu, Yann Ylavic]
+
   *) abs: Include OPENSSL_Applink when compiling on Windows, to resolve
      failures under Visual Studio 2015 and other mismatched MSVCRT flavors.
      PR59630 [Jan Ehrhardt <phpdev ehrhardt.nl>]
index c2a091c49532b4f7bac069b597e06b9321610ed1..ed01aa338d2957665d557544598ddd9ead0de54e 100644 (file)
@@ -677,12 +677,12 @@ static apr_status_t store_body(cache_handle_t *h, request_rec *r, apr_bucket_bri
     apr_read_type_e eblock = APR_BLOCK_READ;
     apr_bucket *e;
     char *cur;
-    int eos = 0;
 
     if (mobj->type == CACHE_TYPE_FILE) {
         apr_file_t *file = NULL;
         int fd = 0;
         int other = 0;
+        int eos = 0;
 
         /* We can cache an open file descriptor if:
          * - the brigade contains one and only one file_bucket &&
@@ -846,6 +846,15 @@ static apr_status_t store_body(cache_handle_t *h, request_rec *r, apr_bucket_bri
          */
         AP_DEBUG_ASSERT(obj->count <= mobj->m_len);
     }
+    if (r->connection->aborted && !obj->complete) {
+        ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r,
+                     "mem_cache: Discarding body for URL %s "
+                     "because client connection was aborted.",
+                     obj->key);
+        /* No need to cleanup - obj->complete unset, so
+         * decrement_refcount will discard the object */
+        return APR_EGENERAL;
+    }
     return APR_SUCCESS;
 }
 /**