------------------------------------------------------------ revno: 11846 revision-id: squid3@treenet.co.nz-20161217102402-vbe31by79bp7y71q parent: squid3@treenet.co.nz-20161217100337-qwu9dk3c1m2i8z0l fixes bug: http://bugs.squid-cache.org/show_bug.cgi?id=3379 author: Garri Djavadyan , Amos Jeffries committer: Amos Jeffries branch nick: 3.2 timestamp: Sat 2016-12-17 23:24:02 +1300 message: Bug 3379: Combination of If-Match and a Cache Hit result in TCP Connection Failure ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20161217102402-vbe31by79bp7y71q # target_branch: http://bzr.squid-cache.org/bzr/squid3/branches\ # /SQUID_3_2 # testament_sha1: edcae67617a80c6c95ed8d6b92ec8c237ebcc66c # timestamp: 2016-12-17 10:24:56 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/3.2 # base_revision_id: squid3@treenet.co.nz-20161217100337-\ # qwu9dk3c1m2i8z0l # # Begin patch === modified file 'src/client_side_reply.cc' --- src/client_side_reply.cc 2012-11-26 08:31:24 +0000 +++ src/client_side_reply.cc 2016-12-17 10:24:02 +0000 @@ -525,6 +525,7 @@ ) { http->logType = LOG_TCP_NEGATIVE_HIT; sendMoreData(result); + return; } else if (!http->flags.internal && refreshCheckHTTP(e, r)) { debugs(88, 5, "clientCacheHit: in refreshCheck() block"); /* @@ -567,25 +568,29 @@ http->logType = LOG_TCP_MISS; processMiss(); } - } else if (r->conditional()) - processConditional(result); - else { - /* - * plain ol' cache hit - */ + return; + } else if (r->conditional()) { + debugs(88, 5, "conditional HIT"); + if (processConditional(result)) + return; + } + + /* + * plain ol' cache hit + */ + debugs(88, 5, "plain old HIT"); #if USE_DELAY_POOLS - if (e->store_status != STORE_OK) - http->logType = LOG_TCP_MISS; - else + if (e->store_status != STORE_OK) + http->logType = LOG_TCP_MISS; + else #endif - if (e->mem_status == IN_MEMORY) - http->logType = LOG_TCP_MEM_HIT; - else if (Config.onoff.offline) - http->logType = LOG_TCP_OFFLINE_HIT; + if (e->mem_status == IN_MEMORY) + http->logType = LOG_TCP_MEM_HIT; + else if (Config.onoff.offline) + http->logType = LOG_TCP_OFFLINE_HIT; - sendMoreData(result); - } + sendMoreData(result); } /** @@ -684,7 +689,7 @@ } /// process conditional request from client -void +bool clientReplyContext::processConditional(StoreIOBuffer &result) { StoreEntry *const e = http->storeEntry(); @@ -694,7 +699,7 @@ e->getReply()->sline.status << " != 200"); http->logType = LOG_TCP_MISS; processMiss(); - return; + return true; } HttpRequest &r = *http->request; @@ -702,7 +707,7 @@ if (r.header.has(HDR_IF_MATCH) && !e->hasIfMatchEtag(r)) { // RFC 2616: reply with 412 Precondition Failed if If-Match did not match sendPreconditionFailedError(); - return; + return true; } bool matchedIfNoneMatch = false; @@ -715,14 +720,14 @@ r.header.delById(HDR_IF_MODIFIED_SINCE); http->logType = LOG_TCP_MISS; sendMoreData(result); - return; + return true; } if (!r.flags.ims) { // RFC 2616: if If-None-Match matched and there is no IMS, // reply with 304 Not Modified or 412 Precondition Failed sendNotModifiedOrPreconditionFailedError(); - return; + return true; } // otherwise check IMS below to decide if we reply with 304 or 412 @@ -734,19 +739,20 @@ if (e->modifiedSince(&r)) { http->logType = LOG_TCP_IMS_HIT; sendMoreData(result); - return; - } - if (matchedIfNoneMatch) { + } else if (matchedIfNoneMatch) { // If-None-Match matched, reply with 304 Not Modified or // 412 Precondition Failed sendNotModifiedOrPreconditionFailedError(); - return; + + } else { + // otherwise reply with 304 Not Modified + sendNotModified(); } - - // otherwise reply with 304 Not Modified - sendNotModified(); + return true; } + + return false; } void === modified file 'src/client_side_reply.h' --- src/client_side_reply.h 2012-01-07 06:05:46 +0000 +++ src/client_side_reply.h 2016-12-17 10:24:02 +0000 @@ -132,7 +132,7 @@ bool alwaysAllowResponse(http_status sline) const; int checkTransferDone(); void processOnlyIfCachedMiss(); - void processConditional(StoreIOBuffer &result); + bool processConditional(StoreIOBuffer &result); void cacheHit(StoreIOBuffer result); void handleIMSReply(StoreIOBuffer result); void sendMoreData(StoreIOBuffer result);