Bug 1304566 - Unregister from the obsever service in order to prevent re-entrancy; r=janv a=gchang
authorEhsan Akhgari <ehsan@mozilla.com>
Sat, 15 Apr 2017 23:26:09 -0400
changeset 396073 2ba2c31b685a23e226267f307303dc68299d8e1b
parent 396072 fdf45ba25f3d116ae3a80f6c33068ebd1ccca202
child 396074 0dc3a0278058d0ff423496e5579e39c99a3c2ef4
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjanv, gchang
bugs1304566
milestone54.0
Bug 1304566 - Unregister from the obsever service in order to prevent re-entrancy; r=janv a=gchang
dom/quota/ActorsParent.cpp
--- a/dom/quota/ActorsParent.cpp
+++ b/dom/quota/ActorsParent.cpp
@@ -2453,16 +2453,28 @@ QuotaManager::
 ShutdownObserver::Observe(nsISupports* aSubject,
                           const char* aTopic,
                           const char16_t* aData)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(!strcmp(aTopic, PROFILE_BEFORE_CHANGE_QM_OBSERVER_ID));
   MOZ_ASSERT(gInstance);
 
+  nsCOMPtr<nsIObserverService> observerService =
+    mozilla::services::GetObserverService();
+  if (NS_WARN_IF(!observerService)) {
+    return NS_ERROR_FAILURE;
+  }
+
+  // Unregister ourselves from the observer service first to make sure the
+  // nested event loop below will not cause re-entrancy issues.
+  Unused <<
+    observerService->RemoveObserver(this,
+                                    PROFILE_BEFORE_CHANGE_QM_OBSERVER_ID);
+
   QuotaManagerService* qms = QuotaManagerService::Get();
   MOZ_ASSERT(qms);
 
   qms->NoteShuttingDownManager();
 
   for (RefPtr<Client>& client : gInstance->mClients) {
     client->WillShutdown();
   }