]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix delay pool DeferredRead in HttpStateData
authorAmos Jeffries <squid3@treenet.co.nz>
Thu, 13 Nov 2014 12:09:11 +0000 (04:09 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 13 Nov 2014 12:09:11 +0000 (04:09 -0800)
The deferred read action may have been delayed so long the read(2) is no
longer possible. It needs to restart from watching the socket instead of
just from performing read(2). This re-adds part of the latency when
delaying traffic but we retain the bytesWanted() speed up so not a big
loss.

src/http.cc

index 4caa3d1146b3af5c31e1d42322337f9f75b2540d..161122a24dd14dafb6042dd17d366eabbeeca2e1 100644 (file)
@@ -24,6 +24,7 @@
 #include "comm/Connection.h"
 #include "comm/Read.h"
 #include "comm/Write.h"
+#include "CommRead.h"
 #include "err_detail_type.h"
 #include "errorpage.h"
 #include "fd.h"
@@ -1126,6 +1127,15 @@ HttpStateData::persistentConnStatus() const
     return statusIfComplete();
 }
 
+#if USE_DELAY_POOLS
+static void
+readDelayed(void *context, CommRead const &)
+{
+    HttpStateData *state = static_cast<HttpStateData*>(context);
+    state->maybeReadVirginBody();
+}
+#endif
+
 void
 HttpStateData::readReply(const CommIoCbParams &io)
 {
@@ -1161,18 +1171,16 @@ HttpStateData::readReply(const CommIoCbParams &io)
     if (rd.size < 1) {
         assert(entry->mem_obj);
 
-        typedef CommCbMemFunT<HttpStateData, CommIoCbParams> Dialer;
-        AsyncCall::Pointer call = JobCallback(11, 5, Dialer, this, HttpStateData::readReply);
-
         /* read ahead limit */
         /* Perhaps these two calls should both live in MemObject */
+        AsyncCall::Pointer nilCall;
         if (!entry->mem_obj->readAheadPolicyCanRead()) {
-            entry->mem_obj->delayRead(DeferredRead(DeferReader, this, CommRead(io.conn, NULL, 0, call)));
+            entry->mem_obj->delayRead(DeferredRead(readDelayed, this, CommRead(io.conn, NULL, 0, nilCall)));
             return;
         }
 
         /* delay id limit */
-        entry->mem_obj->mostBytesAllowed().delayRead(DeferredRead(DeferReader, this, CommRead(io.conn, NULL, 0, call)));
+        entry->mem_obj->mostBytesAllowed().delayRead(DeferredRead(readDelayed, this, CommRead(io.conn, NULL, 0, nilCall)));
         return;
     }
 #endif