From 1d7081d1e4b405f6acae9a35733a0193ed0370aa Mon Sep 17 00:00:00 2001 From: Fedor Date: Wed, 9 Sep 2020 17:29:54 +0300 Subject: [PATCH] Improve resilience of AbortSignals. --- dom/abort/AbortSignal.cpp | 9 ++++++++- dom/abort/moz.build | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/dom/abort/AbortSignal.cpp b/dom/abort/AbortSignal.cpp index 20f36d2ab..7ee6c49a9 100644 --- a/dom/abort/AbortSignal.cpp +++ b/dom/abort/AbortSignal.cpp @@ -56,9 +56,16 @@ AbortSignal::Aborted() const void AbortSignal::Abort() { - MOZ_ASSERT(!mAborted); + // Re-entrancy guard + if (mAborted) { + return; + } mAborted = true; + // We might be deleted as a result of aborting a follower, so ensure we + // stay alive until all followers have been aborted. + RefPtr pinThis = this; + // Let's inform the followers. for (uint32_t i = 0; i < mFollowers.Length(); ++i) { mFollowers[i]->Aborted(); diff --git a/dom/abort/moz.build b/dom/abort/moz.build index cb48ee15f..eacc9ddc7 100644 --- a/dom/abort/moz.build +++ b/dom/abort/moz.build @@ -14,7 +14,7 @@ EXPORTS.mozilla.dom += [ 'AbortSignal.h', ] -UNIFIED_SOURCES += [ +SOURCES += [ 'AbortController.cpp', 'AbortSignal.cpp', ]