File SQUID-2016_11.patch of Package squid.3919

------------------------------------------------------------
revno: 12703
revision-id: squid3@treenet.co.nz-20161217083447-slshkwztlypvxz8v
parent: squid3@treenet.co.nz-20161217075525-cc2lph0uqes0drek
fixes bug: http://bugs.squid-cache.org/show_bug.cgi?id=3379
author: Garri Djavadyan <garryd@comnet.uz>, Amos Jeffries <squid3@treenet.co.nz>
committer: Amos Jeffries <squid3@treenet.co.nz>
branch nick: 3.3
timestamp: Sat 2016-12-17 21:34:47 +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-20161217083447-slshkwztlypvxz8v
# target_branch: http://bzr.squid-cache.org/bzr/squid3/3.3
# testament_sha1: b49c4ceb576b58aeb275452197c813f66c7c9755
# timestamp: 2016-12-17 08:51:13 +0000
# source_branch: http://bzr.squid-cache.org/bzr/squid3/3.3
# base_revision_id: squid3@treenet.co.nz-20161217075525-\
#   cc2lph0uqes0drek
# 
# Begin patch
=== modified file 'src/client_side_reply.cc'
--- src/client_side_reply.cc	2014-03-09 02:35:19 +0000
+++ src/client_side_reply.cc	2016-12-17 08:34:47 +0000
@@ -563,6 +563,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");
         /*
@@ -609,25 +610,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);
 }
 
 /**
@@ -726,7 +731,7 @@
 }
 
 /// process conditional request from client
-void
+bool
 clientReplyContext::processConditional(StoreIOBuffer &result)
 {
     StoreEntry *const e = http->storeEntry();
@@ -736,7 +741,7 @@
                e->getReply()->sline.status << " != 200");
         http->logType = LOG_TCP_MISS;
         processMiss();
-        return;
+        return true;
     }
 
     HttpRequest &r = *http->request;
@@ -744,7 +749,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;
@@ -757,14 +762,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
@@ -776,19 +781,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	2014-03-09 02:35:19 +0000
+++ src/client_side_reply.h	2016-12-17 08:34:47 +0000
@@ -137,7 +137,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);

------------------------------------------------------------
revno: 12704
revision-id: squid3@treenet.co.nz-20161217100442-tf8j6qu85kk47vmy
parent: squid3@treenet.co.nz-20161217083447-slshkwztlypvxz8v
fixes bug: http://bugs.squid-cache.org/show_bug.cgi?id=4169
author: Garri Djavadyan <garryd@comnet.uz>
committer: Amos Jeffries <squid3@treenet.co.nz>
branch nick: 3.3
timestamp: Sat 2016-12-17 23:04:42 +1300
message:
  Bug 4169: HIT marked as MISS when If-None-Match does not match
------------------------------------------------------------
# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: squid3@treenet.co.nz-20161217100442-tf8j6qu85kk47vmy
# target_branch: http://bzr.squid-cache.org/bzr/squid3/3.3
# testament_sha1: 1385c42f15d99bb7831aa28b80b48bfd6e489cc2
# timestamp: 2016-12-17 10:06:32 +0000
# source_branch: http://bzr.squid-cache.org/bzr/squid3/3.3
# base_revision_id: squid3@treenet.co.nz-20161217083447-\
#   slshkwztlypvxz8v
# 
# Begin patch
=== modified file 'src/client_side.cc'
--- src/client_side.cc	2015-08-28 13:25:15 +0000
+++ src/client_side.cc	2016-12-17 10:04:42 +0000
@@ -474,6 +474,7 @@
         statCounter.client_http.nearHitSvcTime.count(svc_time);
         break;
 
+    case LOG_TCP_INM_HIT:
     case LOG_TCP_IMS_HIT:
         statCounter.client_http.nearMissSvcTime.count(svc_time);
         break;

=== modified file 'src/client_side_reply.cc'
--- src/client_side_reply.cc	2016-12-17 08:34:47 +0000
+++ src/client_side_reply.cc	2016-12-17 10:04:42 +0000
@@ -752,40 +752,27 @@
         return true;
     }
 
-    bool matchedIfNoneMatch = false;
     if (r.header.has(HDR_IF_NONE_MATCH)) {
-        if (!e->hasIfNoneMatchEtag(r)) {
-            // RFC 2616: ignore IMS if If-None-Match did not match
-            r.flags.ims = 0;
-            r.ims = -1;
-            r.imslen = 0;
-            r.header.delById(HDR_IF_MODIFIED_SINCE);
-            http->logType = LOG_TCP_MISS;
-            sendMoreData(result);
-            return true;
-        }
+        // RFC 7232: If-None-Match recipient MUST ignore IMS
+        r.flags.ims = false;
+        r.ims = -1;
+        r.imslen = 0;
+        r.header.delById(HDR_IF_MODIFIED_SINCE);
 
-        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
+        if (e->hasIfNoneMatchEtag(r)) {
             sendNotModifiedOrPreconditionFailedError();
             return true;
         }
 
-        // otherwise check IMS below to decide if we reply with 304 or 412
-        matchedIfNoneMatch = true;
+        // None-Match is true (no ETag matched); treat as an unconditional hit
+        return false;
     }
 
     if (r.flags.ims) {
         // handle If-Modified-Since requests from the client
         if (e->modifiedSince(&r)) {
-            http->logType = LOG_TCP_IMS_HIT;
-            sendMoreData(result);
-
-        } else if (matchedIfNoneMatch) {
-            // If-None-Match matched, reply with 304 Not Modified or
-            // 412 Precondition Failed
-            sendNotModifiedOrPreconditionFailedError();
+            // Modified-Since is true; treat as an unconditional hit
+            return false;
 
         } else {
             // otherwise reply with 304 Not Modified
@@ -1916,7 +1903,12 @@
     StoreEntry *e = http->storeEntry();
     const time_t timestamp = e->timestamp;
     HttpReply *const temprep = e->getReply()->make304();
-    http->logType = LOG_TCP_IMS_HIT;
+    // log as TCP_INM_HIT if code 304 generated for
+    // If-None-Match request
+    if (!http->request->flags.ims)
+        http->logType = LOG_TCP_INM_HIT;
+    else
+        http->logType = LOG_TCP_IMS_HIT;
     removeClientStoreReference(&sc, http);
     createStoreEntry(http->request->method, RequestFlags());
     e = http->storeEntry();

=== modified file 'src/enums.h'
--- src/enums.h	2012-09-20 09:13:58 +0000
+++ src/enums.h	2016-12-17 10:04:42 +0000
@@ -41,6 +41,7 @@
     LOG_TCP_REFRESH_FAIL_ERR,   // refresh from origin failed, error forwarded
     LOG_TCP_REFRESH_MODIFIED,   // refresh from origin replaced existing entry
     LOG_TCP_CLIENT_REFRESH_MISS,
+    LOG_TCP_INM_HIT,
     LOG_TCP_IMS_HIT,
     LOG_TCP_SWAPFAIL_MISS,
     LOG_TCP_NEGATIVE_HIT,

=== modified file 'src/log/access_log.cc'
--- src/log/access_log.cc	2015-05-01 07:21:07 +0000
+++ src/log/access_log.cc	2016-12-17 10:04:42 +0000
@@ -584,6 +584,9 @@
     if (code == LOG_TCP_HIT)
         return 1;
 
+    if (code == LOG_TCP_INM_HIT)
+        return 1;
+
     if (code == LOG_TCP_IMS_HIT)
         return 1;
 

openSUSE Build Service is sponsored by