]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Preserve half-closed transaction context (#605)
authorEduard Bagdasaryan <eduard.bagdasaryan@measurement-factory.com>
Sat, 18 Apr 2020 10:09:00 +0000 (10:09 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Sat, 18 Apr 2020 18:59:14 +0000 (18:59 +0000)
The code monitoring half-closed connections (with half_closed_clients
"on") did not save and did not restore transaction contexts.

src/comm.cc

index 72a1cb1311e31f32472f2390dcd24d5c8bf49e59..6b85af629141f5f6ca253c53ee63ddfc416aedac 100644 (file)
@@ -1639,6 +1639,7 @@ commStartHalfClosedMonitor(int fd)
     debugs(5, 5, HERE << "adding FD " << fd << " to " << *TheHalfClosed);
     assert(isOpen(fd) && !commHasHalfClosedMonitor(fd));
     (void)TheHalfClosed->add(fd); // could also assert the result
+    fd_table[fd].codeContext = CodeContext::Current();
     commPlanHalfClosedCheck(); // may schedule check if we added the first FD
 }
 
@@ -1666,10 +1667,12 @@ commHalfClosedCheck(void *)
         Comm::ConnectionPointer c = new Comm::Connection; // XXX: temporary. make HalfClosed a list of these.
         c->fd = *i;
         if (!fd_table[c->fd].halfClosedReader) { // not reading already
-            AsyncCall::Pointer call = commCbCall(5,4, "commHalfClosedReader",
-                                                 CommIoCbPtrFun(&commHalfClosedReader, NULL));
-            Comm::Read(c, call);
-            fd_table[c->fd].halfClosedReader = call;
+            CallBack(fd_table[c->fd].codeContext, [&c] {
+                AsyncCall::Pointer call = commCbCall(5,4, "commHalfClosedReader",
+                                                     CommIoCbPtrFun(&commHalfClosedReader, nullptr));
+                Comm::Read(c, call);
+                fd_table[c->fd].halfClosedReader = call;
+            });
         } else
             c->fd = -1; // XXX: temporary. prevent c replacement erase closing listed FD
     }