From: Yann Ylavic Date: Tue, 16 Aug 2016 23:36:51 +0000 (+0000) Subject: mod_mem_cache: Don't cache incomplete responses when the client X-Git-Tag: 2.2.32~102 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee20e2b69443dcc9c27c76446b14b70009df3414;p=thirdparty%2Fapache%2Fhttpd.git mod_mem_cache: Don't cache incomplete responses when the client connection is aborted before the body is fully read. PR 45049. Backports: n/a (2.2.x only) Submitted by: Nick Pace , 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 --- diff --git a/CHANGES b/CHANGES index cd1f8f60bb8..5154da64834 100644 --- a/CHANGES +++ b/CHANGES @@ -28,6 +28,10 @@ Changes with Apache 2.2.32 SubstituteInheritBefore on|off directive. PR 57641 [Marc.Stern , 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 , 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 ] diff --git a/modules/cache/mod_mem_cache.c b/modules/cache/mod_mem_cache.c index c2a091c4953..ed01aa338d2 100644 --- a/modules/cache/mod_mem_cache.c +++ b/modules/cache/mod_mem_cache.c @@ -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; } /**