From: Alex Rousskov Date: Fri, 16 May 2008 00:23:52 +0000 (-0600) Subject: Moved cleanup to swangSong, where it belongs. We must not call virtual X-Git-Tag: SQUID_3_1_0_1~45^2~11^2~24^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=414611dc7b947c3d2895db9de25f803ab3789414;p=thirdparty%2Fsquid.git Moved cleanup to swangSong, where it belongs. We must not call virtual functions from the destructor and cleanup requires calling virtual functions. This change also ensures that we do not unlock request and response until we are done with body piping. This change is unrelated to eCAP, but the fixed bugs were exposed by eCAP testing. --- diff --git a/src/Server.cc b/src/Server.cc index 9e03698ee4..1f4e80020d 100644 --- a/src/Server.cc +++ b/src/Server.cc @@ -61,6 +61,13 @@ ServerStateData::ServerStateData(FwdState *theFwdState): AsyncJob("ServerStateDa ServerStateData::~ServerStateData() { + // paranoid: check that swanSong has been called + assert(!requestBodySource); +#if USE_ADAPTATION + assert(!virginBodyDestination); + assert(!adaptedBodySource); +#endif + entry->unlock(); HTTPMSGUNLOCK(request); @@ -69,6 +76,16 @@ ServerStateData::~ServerStateData() fwd = NULL; // refcounted + if (responseBodyBuffer != NULL) { + delete responseBodyBuffer; + responseBodyBuffer = NULL; + } +} + +void +ServerStateData::swanSong() +{ + // get rid of our piping obligations if (requestBodySource != NULL) requestBodySource->clearConsumer(); @@ -76,12 +93,14 @@ ServerStateData::~ServerStateData() cleanAdaptation(); #endif - if (responseBodyBuffer != NULL) { - delete responseBodyBuffer; - responseBodyBuffer = NULL; - } + BodyConsumer::swanSong(); +#if USE_ADAPTATION + Initiator::swanSong(); + BodyProducer::swanSong(); +#endif } + HttpReply * ServerStateData::virginReply() { assert(theVirginReply); diff --git a/src/Server.h b/src/Server.h index 807d08e5f8..77a1e39c1a 100644 --- a/src/Server.h +++ b/src/Server.h @@ -103,6 +103,7 @@ public: virtual void processReplyBody() = 0; //AsyncJob virtual methods + virtual void swanSong(); virtual bool doneAll() const { return #if USE_ADAPTATION Adaptation::Initiator::doneAll() &&