From fa6d2c655fb884b65eb2c2c044a81233a987a06f Mon Sep 17 00:00:00 2001 From: Alex Rousskov Date: Wed, 24 Jul 2013 15:48:45 -0600 Subject: [PATCH] Disconnect StoreEntries before deleting their memory objects. 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 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/store.cc b/src/store.cc index 1dfd617aea..b1004cd483 100644 --- a/src/store.cc +++ b/src/store.cc @@ -397,10 +397,6 @@ StoreEntry::StoreEntry() : StoreEntry::~StoreEntry() { - if (swap_filen >= 0) { - SwapDir &sd = dynamic_cast(*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(*e->store()); + sd.disconnect(*e); + } + e->destroyMemObject(); e->hashDelete(); -- 2.47.2