Bug 1203803 - Remove forced cleanup from FactoryOp::ActorDestroy() since it cause more harm than good; r=khuey a=lizzard
authorJan Varga <jan.varga@gmail.com>
Thu, 22 Oct 2015 08:38:06 +0200
changeset 296596 256f6ecf9437fdecc874fe43e95ceb07a456c178
parent 296595 52dae964a9ed3a641e74ab6f9e0e35e5a53d4dca
child 296597 2f90ffb5ee459777a90e34cea18f6621157bf9c3
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey, lizzard
bugs1203803
milestone43.0a2
Bug 1203803 - Remove forced cleanup from FactoryOp::ActorDestroy() since it cause more harm than good; r=khuey a=lizzard
dom/indexedDB/ActorsParent.cpp
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -5705,24 +5705,30 @@ protected:
 
 private:
   Atomic<bool> mOperationMayProceed;
   bool mActorDestroyed;
 
 public:
   NS_DECL_ISUPPORTS_INHERITED
 
+  bool
+  IsOnOwningThread() const
+  {
+    MOZ_ASSERT(mOwningThread);
+
+    bool current;
+    return NS_SUCCEEDED(mOwningThread->IsOnCurrentThread(&current)) && current;
+  }
+
   void
   AssertIsOnOwningThread() const
   {
-    AssertIsOnBackgroundThread();
-    MOZ_ASSERT(mOwningThread);
-    DebugOnly<bool> current;
-    MOZ_ASSERT(NS_SUCCEEDED(mOwningThread->IsOnCurrentThread(&current)));
-    MOZ_ASSERT(current);
+    MOZ_ASSERT(IsOnBackgroundThread());
+    MOZ_ASSERT(IsOnOwningThread());
   }
 
   void
   NoteActorDestroyed()
   {
     AssertIsOnOwningThread();
 
     mActorDestroyed = true;
@@ -20048,35 +20054,35 @@ FactoryOp::Run()
     case State::WaitingForTransactionsToComplete:
       rv = DispatchToWorkThread();
       break;
 
     case State::SendingResults:
       SendResults();
       return NS_OK;
 
-    // We raced, no need to crash.
-    case State::Completed:
-      return NS_OK;
-
     default:
       MOZ_CRASH("Bad state!");
   }
 
   if (NS_WARN_IF(NS_FAILED(rv)) && mState != State::SendingResults) {
     if (NS_SUCCEEDED(mResultCode)) {
       mResultCode = rv;
     }
 
     // Must set mState before dispatching otherwise we will race with the owning
     // thread.
     mState = State::SendingResults;
 
-    MOZ_ALWAYS_TRUE(NS_SUCCEEDED(mOwningThread->Dispatch(this,
-                                                         NS_DISPATCH_NORMAL)));
+    if (IsOnOwningThread()) {
+      SendResults();
+    } else {
+      MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
+        mOwningThread->Dispatch(this, NS_DISPATCH_NORMAL)));
+    }
   }
 
   return NS_OK;
 }
 
 void
 FactoryOp::DirectoryLockAcquired(DirectoryLock* aLock)
 {
@@ -20109,25 +20115,16 @@ FactoryOp::DirectoryLockFailed()
 }
 
 void
 FactoryOp::ActorDestroy(ActorDestroyReason aWhy)
 {
   AssertIsOnBackgroundThread();
 
   NoteActorDestroyed();
-
-  if (mState == State::WaitingForTransactionsToComplete ||
-      (mState == State::SendingResults && aWhy != Deletion)) {
-    // We didn't get an opportunity to clean up.  Do that now.
-    mState = State::SendingResults;
-    IDB_REPORT_INTERNAL_ERR();
-    mResultCode = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
-    SendResults();
-  }
 }
 
 bool
 FactoryOp::RecvPermissionRetry()
 {
   AssertIsOnOwningThread();
   MOZ_ASSERT(!IsActorDestroyed());
   MOZ_ASSERT(mState == State::PermissionChallenge);
@@ -20866,18 +20863,17 @@ OpenDatabaseOp::BeginVersionChange()
 
 void
 OpenDatabaseOp::NoteDatabaseClosed(Database* aDatabase)
 {
   AssertIsOnOwningThread();
   MOZ_ASSERT(aDatabase);
   MOZ_ASSERT(mState == State::WaitingForOtherDatabasesToClose ||
              mState == State::WaitingForTransactionsToComplete ||
-             mState == State::DatabaseWorkVersionChange ||
-             mState == State::SendingResults);
+             mState == State::DatabaseWorkVersionChange);
 
   if (mState != State::WaitingForOtherDatabasesToClose) {
     MOZ_ASSERT(mMaybeBlockedDatabases.IsEmpty());
     MOZ_ASSERT(mRequestedVersion >
                  aDatabase->Metadata()->mCommonMetadata.version(),
                "Must only be closing databases for a previous version!");
     return;
   }