-#include "squid-old.h"
+#include "squid.h"
#include "base/AsyncJobCalls.h"
#include "base/TextException.h"
#include "BodyPipe.h"
return true;
}
-
/* BodyProducer */
// inform the pipe that we are done and clear the Pointer
pipe = NULL;
}
-
-
/* BodyConsumer */
// inform the pipe that we are done and clear the Pointer
pipe = NULL;
}
-
/* BodyPipe */
BodyPipe::BodyPipe(Producer *aProducer): theBodySize(-1),
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();
}
}
clearProducer(true); // reached end-of-body
}
-
void
BodyPipe::scheduleBodyDataNotification()
{
outputBuffer.append(" [", 2);
- outputBuffer.Printf("%"PRIu64"<=%"PRIu64, theGetSize, thePutSize);
+ outputBuffer.Printf("%" PRIu64 "<=%" PRIu64, theGetSize, thePutSize);
if (theBodySize >= 0)
- outputBuffer.Printf("<=%"PRId64, theBodySize);
+ outputBuffer.Printf("<=%" PRId64, theBodySize);
else
outputBuffer.append("<=?", 3);
return outputBuffer.content();
}
-
/* BodyPipeCheckout */
BodyPipeCheckout::BodyPipeCheckout(BodyPipe &aPipe): pipe(aPipe),
checkedIn = true;
}
-
BodyPipeCheckout::BodyPipeCheckout(const BodyPipeCheckout &c): pipe(c.pipe),
buf(c.buf), offset(c.offset), checkedOutSize(c.checkedOutSize),
checkedIn(c.checkedIn)