]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Polished ServerStateData cleanup code: Moved more cleanup code from the
authorAlex Rousskov <rousskov@measurement-factory.com>
Tue, 30 Sep 2008 16:32:18 +0000 (10:32 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Tue, 30 Sep 2008 16:32:18 +0000 (10:32 -0600)
destructor with its dangers of half-destroyed context to safe swanSong.

src/Server.cc
src/Server.h

index deae0318439de18937f304446ab9206cc12b3bfd..03443fb74c45935e60e584cfa0df13ac6ca86ed4 100644 (file)
@@ -66,6 +66,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);
@@ -74,6 +81,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();
 
@@ -81,12 +98,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 28d4b5f0826111b289a28fad9c9629186404cf24..c7d102ecacf09f39a9ae73460878cde5592a7abe 100644 (file)
@@ -100,6 +100,7 @@ public:
     virtual void processReplyBody() = 0;
 
 //AsyncJob virtual methods
+    virtual void swanSong();
     virtual bool doneAll() const { return
 #if USE_ADAPTATION
                        Adaptation::Initiator::doneAll() &&