Bug 1412320 - CacheIndex::~CacheIndex is called outside CacheIndex::sLock. r=honzab
authorMichal Novotny <michal.novotny@gmail.com>
Thu, 18 Jan 2018 07:14:00 -0500
changeset 400731 f50ee305941a736c99d678413281937627068547
parent 400730 f2ce61d1a59297b7ad3c91496196fa3a0b776aa7
child 400732 040afea6562faf67bcee95090861a0470f64a121
child 400762 0514c55fb1d15577f4c4ab7e98a69b01b1aab139
push id33313
push userncsoregi@mozilla.com
push dateThu, 25 Jan 2018 10:14:49 +0000
treeherdermozilla-central@040afea6562f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershonzab
bugs1412320
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1412320 - CacheIndex::~CacheIndex is called outside CacheIndex::sLock. r=honzab We must close cache iterators before shutting down CacheIndex because they hold reference to CacheIndex which causes that CacheIndex is not destroyed when it's dereferenced in CacheIndex::Shutdown.
netwerk/cache2/CacheFileContextEvictor.cpp
netwerk/cache2/CacheFileContextEvictor.h
netwerk/cache2/CacheFileIOManager.cpp
--- a/netwerk/cache2/CacheFileContextEvictor.cpp
+++ b/netwerk/cache2/CacheFileContextEvictor.cpp
@@ -68,16 +68,26 @@ CacheFileContextEvictor::Init(nsIFile *a
       CreateIterators();
       StartEvicting();
     }
   }
 
   return NS_OK;
 }
 
+void
+CacheFileContextEvictor::Shutdown()
+{
+  LOG(("CacheFileContextEvictor::Shutdown()"));
+
+  MOZ_ASSERT(CacheFileIOManager::IsOnIOThread());
+
+  CloseIterators();
+}
+
 uint32_t
 CacheFileContextEvictor::ContextsCount()
 {
   MOZ_ASSERT(CacheFileIOManager::IsOnIOThread());
 
   return mEntries.Length();
 }
 
--- a/netwerk/cache2/CacheFileContextEvictor.h
+++ b/netwerk/cache2/CacheFileContextEvictor.h
@@ -32,16 +32,17 @@ public:
 
   CacheFileContextEvictor();
 
 private:
   virtual ~CacheFileContextEvictor();
 
 public:
   nsresult Init(nsIFile *aCacheDirectory);
+  void Shutdown();
 
   // Returns number of contexts that are being evicted.
   uint32_t ContextsCount();
   // Start evicting given context.
   nsresult AddContext(nsILoadContextInfo *aLoadContextInfo, bool aPinned);
   // CacheFileIOManager calls this method when CacheIndex's state changes. We
   // check whether the index is up to date and start or stop evicting according
   // to index's state.
--- a/netwerk/cache2/CacheFileIOManager.cpp
+++ b/netwerk/cache2/CacheFileIOManager.cpp
@@ -1349,16 +1349,21 @@ CacheFileIOManager::ShutdownInternal()
   MOZ_ASSERT(mHandles.HandleCount() == 0);
 
   // Release trash directory enumerator
   if (mTrashDirEnumerator) {
     mTrashDirEnumerator->Close();
     mTrashDirEnumerator = nullptr;
   }
 
+  if (mContextEvictor) {
+    mContextEvictor->Shutdown();
+    mContextEvictor = nullptr;
+  }
+
   return NS_OK;
 }
 
 // static
 nsresult
 CacheFileIOManager::OnProfile()
 {
   LOG(("CacheFileIOManager::OnProfile() [gInstance=%p]", gInstance.get()));