mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 1721503: Avoid possible lock-order inversion in shutting down RemoteLazyInputStreamChild r=dom-storage-reviewers,edenchuang
Differential Revision: https://phabricator.services.mozilla.com/D134504
This commit is contained in:
parent
92b57175c3
commit
9e3ccb99f6
@ -155,17 +155,26 @@ RemoteLazyInputStreamChild::RemoteLazyInputStreamChild(const nsID& aID,
|
||||
RemoteLazyInputStreamChild::~RemoteLazyInputStreamChild() = default;
|
||||
|
||||
void RemoteLazyInputStreamChild::Shutdown() {
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
RefPtr<RemoteLazyInputStreamChild> kungFuDeathGrip = this;
|
||||
// Don't delete the pending operations inside our lock, since that might
|
||||
// lead to a lock-ordering inversion
|
||||
nsTArray<PendingOperation> pending;
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
mWorkerRef = nullptr;
|
||||
mPendingOperations.Clear();
|
||||
mWorkerRef = nullptr;
|
||||
pending.SwapElements(mPendingOperations);
|
||||
|
||||
if (mState == eActive) {
|
||||
SendClose();
|
||||
mState = eInactive;
|
||||
if (mState == eActive) {
|
||||
SendClose();
|
||||
mState = eInactive;
|
||||
}
|
||||
}
|
||||
// Now release pending operations.
|
||||
// We could let this be destroyed by scope, but I prefer
|
||||
// to be explicit that we clear this before we drop the
|
||||
// self-reference
|
||||
pending.Clear();
|
||||
}
|
||||
|
||||
void RemoteLazyInputStreamChild::ActorDestroy(
|
||||
|
Loading…
Reference in New Issue
Block a user