From: Alex Rousskov Date: Wed, 7 Mar 2012 00:26:34 +0000 (-0700) Subject: Bug 3420: Request body consumption races and theConsumer X-Git-Tag: BumpSslServerFirst.take06~2^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b84d327b33270c5b998fd0c24de06a0ff8b0bb0a;p=thirdparty%2Fsquid.git Bug 3420: Request body consumption races and theConsumer --- diff --git a/src/BodyPipe.cc b/src/BodyPipe.cc index bdbe3a37a2..3cdefe3d16 100644 --- a/src/BodyPipe.cc +++ b/src/BodyPipe.cc @@ -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(); } }