]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Disconnect StoreEntries before deleting their memory objects.
authorAlex Rousskov <rousskov@measurement-factory.com>
Wed, 24 Jul 2013 21:48:45 +0000 (15:48 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Wed, 24 Jul 2013 21:48:45 +0000 (15:48 -0600)
The new cleanup order helps identify the write Rock entry state (reading or
writing) and avoid assertions related to state identification bugs (such
as unlocking a writing entry for reading).

Similar to the memory cache code, we should not disconnect disk entries during
shutdown because Store::Root() may be missing by then.

src/store.cc

index 1dfd617aea6f407bcaed53bae18043c79e207ff3..b1004cd4836f5950f914d55bc2d09a7ff03d836f 100644 (file)
@@ -397,10 +397,6 @@ StoreEntry::StoreEntry() :
 
 StoreEntry::~StoreEntry()
 {
-    if (swap_filen >= 0) {
-        SwapDir &sd = dynamic_cast<SwapDir&>(*store());
-        sd.disconnect(*this);
-    }
 }
 
 #if USE_ADAPTATION
@@ -452,6 +448,12 @@ destroyStoreEntry(void *data)
     if (e == NullStoreEntry::getInstance())
         return;
 
+    // Store::Root() is FATALly missing during shutdown
+    if (e->swap_filen >= 0 && !shutting_down) {
+        SwapDir &sd = dynamic_cast<SwapDir&>(*e->store());
+        sd.disconnect(*e);
+    }
+
     e->destroyMemObject();
 
     e->hashDelete();