Commit 5e575d63 authored by valenting's avatar valenting
Browse files

Bug 1742334 - Make sure to null out ChannelEventQueue::mOwner when object is...

Bug 1742334 - Make sure to null out ChannelEventQueue::mOwner when object is released r=necko-reviewers,dragana

Differential Revision: https://phabricator.services.mozilla.com/D131896
parent e935b21f
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -34,7 +34,11 @@ void ChannelEventQueue::FlushQueue() {
  // Events flushed could include destruction of channel (and our own
  // destructor) unless we make sure its refcount doesn't drop to 0 while this
  // method is running.
  nsCOMPtr<nsISupports> kungFuDeathGrip(mOwner);
  nsCOMPtr<nsISupports> kungFuDeathGrip;
  {
    MutexAutoLock lock(mMutex);
    kungFuDeathGrip = mOwner;
  }
  mozilla::Unused << kungFuDeathGrip;  // Not used in this function

#ifdef DEBUG
@@ -156,6 +160,10 @@ void ChannelEventQueue::ResumeInternal() {
      nsCOMPtr<nsISupports> mOwner;
    };

    if (!mOwner) {
      return;
    }

    // Worker thread requires a CancelableRunnable.
    RefPtr<Runnable> event = new CompleteResumeRunnable(this, mOwner);

+5 −0
Original line number Diff line number Diff line
@@ -147,6 +147,11 @@ class ChannelEventQueue final {
  // dispatched in a new event on the current thread.
  void Resume();

  void NotifyReleasingOwner() {
    MutexAutoLock lock(mMutex);
    mOwner = nullptr;
  }

#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
  bool IsEmpty() const { return mEventQueue.IsEmpty(); }
#endif
+2 −0
Original line number Diff line number Diff line
@@ -141,6 +141,8 @@ HttpChannelChild::~HttpChannelChild() {
  }
#endif

  mEventQ->NotifyReleasingOwner();

  ReleaseMainThreadOnlyReferences();
}

+1 −0
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@ HttpChannelParent::~HttpChannelParent() {
    mRedirectCallback->OnRedirectVerifyCallback(NS_ERROR_UNEXPECTED);
    mRedirectCallback = nullptr;
  }
  mEventQ->NotifyReleasingOwner();
}

void HttpChannelParent::ActorDestroy(ActorDestroyReason why) {
+1 −0
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ HttpTransactionParent::HttpTransactionParent(bool aIsDocumentLoad)

HttpTransactionParent::~HttpTransactionParent() {
  LOG(("Destroying HttpTransactionParent @%p\n", this));
  mEventQ->NotifyReleasingOwner();
}

//-----------------------------------------------------------------------------
Loading