]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 3420: Request body consumption races and theConsumer
authorAlex Rousskov <rousskov@measurement-factory.com>
Wed, 7 Mar 2012 00:26:34 +0000 (17:26 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 7 Mar 2012 00:26:34 +0000 (17:26 -0700)
src/BodyPipe.cc

index bdbe3a37a2953ba895d810a901f5563a2cc0b9d2..3cdefe3d16c55248397dd29614770b92b026e9d4 100644 (file)
@@ -268,14 +268,28 @@ BodyPipe::clearConsumer()
 void
 BodyPipe::expectNoConsumption()
 {
-    Must(!theConsumer);
+    // We may be called multiple times because multiple jobs on the consumption
+    // chain may realize that there will be no more setConsumer() calls (e.g.,
+    // consuming code and retrying code). It is both difficult and not really
+    // necessary for them to coordinate their expectNoConsumption() calls.
+
+    // As a consequence, we may be called when we are auto-consuming already.
+
     if (!abortedConsumption && !exhausted()) {
+        // Before we abort, any regular consumption should be over and auto
+               // consumption must not be started.
+        Must(!theConsumer);
+
         AsyncCall::Pointer call= asyncCall(91, 7,
                                            "BodyProducer::noteBodyConsumerAborted",
                                            BodyProducerDialer(theProducer,
                                                               &BodyProducer::noteBodyConsumerAborted, this));
         ScheduleCallHere(call);
         abortedConsumption = true;
+
+        // in case somebody enabled auto-consumption before regular one aborted
+        if (mustAutoConsume)
+            startAutoConsumption();
     }
 }