From 23e05fb16e0848dbb220833135781be7d50b5e6d Mon Sep 17 00:00:00 2001 From: Alex Rousskov Date: Sun, 12 Sep 2010 18:34:44 -0600 Subject: [PATCH] Partial bug #2964 fix: writer stuck in a "waiting for preview answer" state. At the end of preview, do not go into the writingPaused state if we already received the final response from the ICAP server. Instead, stop writing so that we do not get stuck waiting for the response that has already come. May also handle header-only (zero-size) ieof Preview better. --- src/adaptation/icap/ModXact.cc | 34 +++++++++++++++++++++++----------- src/adaptation/icap/ModXact.h | 1 + 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/adaptation/icap/ModXact.cc b/src/adaptation/icap/ModXact.cc index f08abdf328..abb3b41329 100644 --- a/src/adaptation/icap/ModXact.cc +++ b/src/adaptation/icap/ModXact.cc @@ -160,11 +160,14 @@ void Adaptation::Icap::ModXact::handleCommWroteHeaders() Must(state.writing == State::writingHeaders); // determine next step - if (preview.enabled()) - state.writing = preview.done() ? State::writingPaused : State::writingPreview; - else if (virginBody.expected()) + if (preview.enabled()) { + if (preview.done()) + decideWritingAfterPreview("zero-size"); + else + state.writing = State::writingPreview; + } else if (virginBody.expected()) { state.writing = State::writingPrime; - else { + } else { stopWriting(true); return; } @@ -223,14 +226,23 @@ void Adaptation::Icap::ModXact::writePreviewBody() // change state once preview is written - if (preview.done()) { - debugs(93, 7, HERE << "wrote entire Preview body" << status()); + if (preview.done()) + decideWritingAfterPreview("body"); +} - if (preview.ieof()) - stopWriting(true); - else - state.writing = State::writingPaused; - } +/// determine state.writing after we wrote the entire preview +void Adaptation::Icap::ModXact::decideWritingAfterPreview(const char *kind) +{ + if (preview.ieof()) // nothing more to write + stopWriting(true); + else + if (state.parsing == State::psIcapHeader) // did not get a reply yet + state.writing = State::writingPaused; // wait for the ICAP server reply + else + stopWriting(true); // ICAP server reply implies no post-preview writing + + debugs(93, 6, HERE << "decided on writing after " << kind << " preview" << + status()); } void Adaptation::Icap::ModXact::writePrimeBody() diff --git a/src/adaptation/icap/ModXact.h b/src/adaptation/icap/ModXact.h index 0cad76a905..fb08d02e55 100644 --- a/src/adaptation/icap/ModXact.h +++ b/src/adaptation/icap/ModXact.h @@ -184,6 +184,7 @@ private: void writePreviewBody(); void writePrimeBody(); void writeSomeBody(const char *label, size_t size); + void decideWritingAfterPreview(const char *previewKind); void startReading(); void readMore(); -- 2.47.3