]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Moved cleanup to swangSong, where it belongs. We must not call virtual
authorAlex Rousskov <rousskov@measurement-factory.com>
Fri, 16 May 2008 00:23:52 +0000 (18:23 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Fri, 16 May 2008 00:23:52 +0000 (18:23 -0600)
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.

src/Server.cc
src/Server.h

index 9e03698ee4defa44b24eafb8999efa07073daa3f..1f4e80020d9486316f5fb637b7cc3a637822f3f9 100644 (file)
@@ -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);
index 807d08e5f84db7410612b3a37fafcb622bc61f73..77a1e39c1a84904cc3e84f8b95ef308f1364ba11 100644 (file)
@@ -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() &&