Skip to content

Commit

Permalink
Bug 4919: master commit b599471 leaks memory (squid-cache#364) (squid…
Browse files Browse the repository at this point in the history
…-cache#368)

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.
  • Loading branch information
squidadm authored and yadij committed Feb 17, 2019
1 parent 1e3da85 commit 607b68b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/BodyPipe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit 607b68b

Please sign in to comment.