Bug 1415120 - Part1: no db access while rebuilding, r=nwgh a=gchang
authorJunior Hsu <juhsu@mozilla.com>
Wed, 15 Nov 2017 20:03:00 +0200
changeset 444889 3615c481c3de6a5fa04c0adf51e9707c37ff7fb2
parent 444888 3f82ccf7f33a62eeeea1cc402f8bb9ab259ac480
child 444890 dc110b1bf70ae2d7653b3b6cbddd17f22e435bbe
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnwgh, gchang
bugs1415120
milestone58.0
Bug 1415120 - Part1: no db access while rebuilding, r=nwgh a=gchang
netwerk/cookie/nsCookieService.cpp
--- a/netwerk/cookie/nsCookieService.cpp
+++ b/netwerk/cookie/nsCookieService.cpp
@@ -1724,16 +1724,17 @@ nsCookieService::CloseDBStates()
   if (mDefaultDBState->dbConn) {
     // Asynchronously close the connection. We will null it below.
     mDefaultDBState->dbConn->AsyncClose(mDefaultDBState->closeListener);
   }
 
   CleanupDefaultDBConnection();
 
   mDefaultDBState = nullptr;
+  mInitializedDBConn = false;
   mInitializedDBStates = false;
 }
 
 // Null out the statements.
 // This must be done before closing the connection.
 void
 nsCookieService::CleanupCachedStatements()
 {
@@ -1760,18 +1761,16 @@ nsCookieService::CleanupDefaultDBConnect
 
   // Manually null out our listeners. This is necessary because they hold a
   // strong ref to the DBState itself. They'll stay alive until whatever
   // statements are still executing complete.
   mDefaultDBState->insertListener = nullptr;
   mDefaultDBState->updateListener = nullptr;
   mDefaultDBState->removeListener = nullptr;
   mDefaultDBState->closeListener = nullptr;
-
-  mInitializedDBConn = false;
 }
 
 void
 nsCookieService::HandleDBClosed(DBState* aDBState)
 {
   COOKIE_LOGSTRING(LogLevel::Debug,
     ("HandleDBClosed(): DBState %p closed", aDBState));
 
@@ -1911,17 +1910,17 @@ nsCookieService::RebuildCorruptDB(DBStat
             return;
           }
 
           // Notify observers that we're beginning the rebuild.
           if (os) {
             os->NotifyObservers(nullptr, "cookie-db-rebuilding", nullptr);
           }
 
-          gCookieService->InitDBConn();
+          gCookieService->InitDBConnInternal();
 
           // Enumerate the hash, and add cookies to the params array.
           mozIStorageAsyncStatement* stmt = gCookieService->mDefaultDBState->stmtInsert;
           nsCOMPtr<mozIStorageBindingParamsArray> paramsArray;
           stmt->NewBindingParamsArray(getter_AddRefs(paramsArray));
           for (auto iter = gCookieService->mDefaultDBState->hostTable.Iter();
                !iter.Done();
                iter.Next()) {