Bug 1112620 - Fix invalidated version change transactions. r=khuey, a=sledru
authorBen Turner <bent.mozilla@gmail.com>
Tue, 31 Mar 2015 15:35:12 -0700
changeset 258274 f8e17839eac9
parent 258273 0e9a4f42d12a
child 258275 7b6bd63b68e5
push id4633
push userryanvm@gmail.com
push date2015-04-06 15:44 +0000
treeherdermozilla-beta@e749a39aaf5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey, sledru
bugs1112620
milestone38.0
Bug 1112620 - Fix invalidated version change transactions. r=khuey, a=sledru
dom/indexedDB/ActorsParent.cpp
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -3419,17 +3419,17 @@ protected:
 
   bool
   DeallocCursor(PBackgroundIDBCursorParent* aActor);
 
   virtual void
   UpdateMetadata(nsresult aResult)
   { }
 
-  virtual bool
+  virtual void
   SendCompleteNotification(nsresult aResult) = 0;
 
 private:
   // Only called by CommitOp.
   void
   ReleaseTransactionThreadObjects();
 
   // Only called by CommitOp.
@@ -3718,17 +3718,17 @@ private:
   // Reference counted.
   ~NormalTransaction()
   { }
 
   bool
   IsSameProcessActor();
 
   // Only called by TransactionBase.
-  virtual bool
+  virtual void
   SendCompleteNotification(nsresult aResult) override;
 
   // IPDL methods are only called by IPDL.
   virtual void
   ActorDestroy(ActorDestroyReason aWhy) override;
 
   virtual bool
   RecvDeleteMe() override;
@@ -3792,17 +3792,17 @@ private:
   void
   SetActorAlive();
 
   // Only called by TransactionBase.
   virtual void
   UpdateMetadata(nsresult aResult) override;
 
   // Only called by TransactionBase.
-  virtual bool
+  virtual void
   SendCompleteNotification(nsresult aResult) override;
 
   // IPDL methods are only called by IPDL.
   virtual void
   ActorDestroy(ActorDestroyReason aWhy) override;
 
   virtual bool
   RecvDeleteMe() override;
@@ -7809,41 +7809,43 @@ NormalTransaction::IsSameProcessActor()
   AssertIsOnBackgroundThread();
 
   PBackgroundParent* actor = Manager()->Manager()->Manager();
   MOZ_ASSERT(actor);
 
   return !BackgroundParent::IsOtherProcessActor(actor);
 }
 
-bool
+void
 NormalTransaction::SendCompleteNotification(nsresult aResult)
 {
   AssertIsOnBackgroundThread();
 
-  return IsActorDestroyed() || !NS_WARN_IF(!SendComplete(aResult));
+  if (!IsActorDestroyed()) {
+    unused << SendComplete(aResult);
+  }
 }
 
 void
 NormalTransaction::ActorDestroy(ActorDestroyReason aWhy)
 {
   AssertIsOnBackgroundThread();
 
+  NoteActorDestroyed();
+
   if (!mCommittedOrAborted) {
     if (NS_SUCCEEDED(mResultCode)) {
       IDB_REPORT_INTERNAL_ERR();
       mResultCode = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
     }
 
     mForceAborted = true;
 
     MaybeCommitOrAbort();
   }
-
-  NoteActorDestroyed();
 }
 
 bool
 NormalTransaction::RecvDeleteMe()
 {
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(!IsActorDestroyed());
 
@@ -8013,18 +8015,18 @@ VersionChangeTransaction::CopyDatabaseMe
 }
 
 void
 VersionChangeTransaction::UpdateMetadata(nsresult aResult)
 {
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(GetDatabase());
   MOZ_ASSERT(mOpenDatabaseOp);
-  MOZ_ASSERT(mOpenDatabaseOp->mDatabase);
-  MOZ_ASSERT(!mOpenDatabaseOp->mDatabaseId.IsEmpty());
+  MOZ_ASSERT(!!mActorWasAlive == !!mOpenDatabaseOp->mDatabase);
+  MOZ_ASSERT_IF(mActorWasAlive, !mOpenDatabaseOp->mDatabaseId.IsEmpty());
 
   class MOZ_STACK_CLASS Helper final
   {
   public:
     static PLDHashOperator
     Enumerate(const uint64_t& aKey,
               nsRefPtr<FullObjectStoreMetadata>& aValue,
               void* /* aClosure */)
@@ -8056,17 +8058,17 @@ VersionChangeTransaction::UpdateMetadata
       if (aValue->mDeleted) {
         return PL_DHASH_REMOVE;
       }
 
       return PL_DHASH_NEXT;
     }
   };
 
-  if (IsActorDestroyed()) {
+  if (IsActorDestroyed() || !mActorWasAlive) {
     return;
   }
 
   nsRefPtr<FullDatabaseMetadata> oldMetadata;
   mOldMetadata.swap(oldMetadata);
 
   DatabaseActorInfo* info;
   if (!gLiveDatabaseHashtable->Get(oldMetadata->mDatabaseId, &info)) {
@@ -8088,55 +8090,62 @@ VersionChangeTransaction::UpdateMetadata
     for (uint32_t count = info->mLiveDatabases.Length(), index = 0;
          index < count;
          index++) {
       info->mLiveDatabases[index]->mMetadata = info->mMetadata;
     }
   }
 }
 
-bool
+void
 VersionChangeTransaction::SendCompleteNotification(nsresult aResult)
 {
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(mOpenDatabaseOp);
+  MOZ_ASSERT_IF(!mActorWasAlive, NS_FAILED(mOpenDatabaseOp->mResultCode));
+  MOZ_ASSERT_IF(!mActorWasAlive,
+                mOpenDatabaseOp->mState > OpenDatabaseOp::State_SendingResults);
 
   nsRefPtr<OpenDatabaseOp> openDatabaseOp;
   mOpenDatabaseOp.swap(openDatabaseOp);
 
+  if (!mActorWasAlive) {
+    return;
+  }
+
   if (NS_FAILED(aResult) && NS_SUCCEEDED(openDatabaseOp->mResultCode)) {
     openDatabaseOp->mResultCode = aResult;
   }
 
   openDatabaseOp->mState = OpenDatabaseOp::State_SendingResults;
 
-  bool result = IsActorDestroyed() || !NS_WARN_IF(!SendComplete(aResult));
+  if (!IsActorDestroyed()) {
+    unused << SendComplete(aResult);
+  }
 
   MOZ_ALWAYS_TRUE(NS_SUCCEEDED(openDatabaseOp->Run()));
-
-  return result;
 }
 
 void
 VersionChangeTransaction::ActorDestroy(ActorDestroyReason aWhy)
 {
   AssertIsOnBackgroundThread();
 
+  NoteActorDestroyed();
+
   if (!mCommittedOrAborted) {
     if (NS_SUCCEEDED(mResultCode)) {
       IDB_REPORT_INTERNAL_ERR();
       mResultCode = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
     }
 
     mForceAborted = true;
 
     MaybeCommitOrAbort();
   }
-
-  NoteActorDestroyed();
 }
 
 bool
 VersionChangeTransaction::RecvDeleteMe()
 {
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(!IsActorDestroyed());