Bug 1256049: Correctly handle databases currently performing maintenance when a new transaction is started. r=janv
authorKyle Huey <khuey@kylehuey.com>
Tue, 05 Apr 2016 20:21:25 -0700
changeset 291853 d08f6e50f306ccfa2e462d6221044b4ce0748f47
parent 291852 c7bed3468b5d85f9bf82eb72d1a0b9fbffd6a4fc
child 291854 5d456db9e320022548bf0a90b8b7d6196cae24fc
push idunknown
push userunknown
push dateunknown
reviewersjanv
bugs1256049
milestone48.0a1
Bug 1256049: Correctly handle databases currently performing maintenance when a new transaction is started. r=janv
dom/indexedDB/ActorsParent.cpp
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -11545,17 +11545,19 @@ ConnectionPool::Start(const nsID& aBackg
     }
   }
 
   if (!transactionInfo->mBlockedOn.Count()) {
     Unused << ScheduleTransaction(transactionInfo,
                                   /* aFromQueuedTransactions */ false);
   }
 
-  if (!databaseInfoIsNew && mIdleDatabases.RemoveElement(dbInfo)) {
+  if (!databaseInfoIsNew &&
+      (mIdleDatabases.RemoveElement(dbInfo) ||
+       mDatabasesPerformingIdleMaintenance.RemoveElement(dbInfo))) {
     AdjustIdleTimer();
   }
 
   return transactionId;
 }
 
 void
 ConnectionPool::Dispatch(uint64_t aTransactionId, nsIRunnable* aRunnable)
@@ -12412,27 +12414,25 @@ IdleConnectionRunnable::Run()
     MOZ_ALWAYS_SUCCEEDS(
       owningThread->Dispatch(this, NS_DISPATCH_NORMAL));
     return NS_OK;
   }
 
   RefPtr<ConnectionPool> connectionPool = mDatabaseInfo->mConnectionPool;
   MOZ_ASSERT(connectionPool);
 
-  if (mDatabaseInfo->mClosing) {
+  if (mDatabaseInfo->mClosing || mDatabaseInfo->TotalTransactionCount()) {
     MOZ_ASSERT(!connectionPool->
                  mDatabasesPerformingIdleMaintenance.Contains(mDatabaseInfo));
   } else {
     MOZ_ALWAYS_TRUE(
       connectionPool->
         mDatabasesPerformingIdleMaintenance.RemoveElement(mDatabaseInfo));
 
-    if (!mDatabaseInfo->TotalTransactionCount()) {
-      connectionPool->NoteIdleDatabase(mDatabaseInfo);
-    }
+    connectionPool->NoteIdleDatabase(mDatabaseInfo);
   }
 
   return NS_OK;
 }
 
 NS_IMPL_ISUPPORTS_INHERITED0(ConnectionPool::CloseConnectionRunnable,
                              ConnectionPool::ConnectionRunnable)