From: Alex Rousskov Date: Thu, 14 Feb 2019 18:48:56 +0000 (+0000) Subject: Bug 4919: master commit b599471 leaks memory (#364) X-Git-Tag: M-staged-PR364 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=664dc2670410b8498b550b3c0402ab61992e615b;p=thirdparty%2Fsquid.git Bug 4919: master commit b599471 leaks memory (#364) Restored the natural order of the following two notifications: * BodyConsumer::noteMoreBodyDataAvailable() and * BodyConsumer::noteBodyProductionEnded() or noteBodyProducerAborted(). Commit b599471 unintentionally reordered those two notifications. Client kids (and possibly other BodyConsumers) relied on the natural order to end their work. If an HttpStateData job was done with the Squid-to-peer connection and only waiting for the last adapted body bytes, it would get stuck and leak many objects. This use case was not tested during b599471 work. --- diff --git a/src/BodyPipe.cc b/src/BodyPipe.cc index 551f0a5383..69b49ad4a5 100644 --- a/src/BodyPipe.cc +++ b/src/BodyPipe.cc @@ -397,13 +397,15 @@ BodyPipe::postAppend(size_t size) thePutSize += size; debugs(91,7, HERE << "added " << size << " bytes" << status()); - if (!mayNeedMoreData()) - clearProducer(true); // reached end-of-body - // We should not consume here even if mustAutoConsume because the // caller may not be ready for the data to be consumed during this call. scheduleBodyDataNotification(); + // Do this check after scheduleBodyDataNotification() to ensure the + // natural order of "more body data" and "production ended" events. + if (!mayNeedMoreData()) + clearProducer(true); // reached end-of-body + startAutoConsumptionIfNeeded(); }