зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1635196 - Make sure profile-gathering promise is fulfilled before destroying holder - r=mstange
While gathering profiles from child processes, some actions (e.g., shutting down, restarting the profiler) may reset the gathering operation. In this case we must ensure that the promise is rejected if not already fulfilled, so that anyone waiting on it won't be blocked forever (and MozPromise enforces it in a MOZ_DIAGNOSTIC_ASSERT). Differential Revision: https://phabricator.services.mozilla.com/D73790
This commit is contained in:
Родитель
d8308aa13f
Коммит
52ffb43ad5
|
@ -59,6 +59,7 @@ nsProfiler::~nsProfiler() {
|
|||
if (mSymbolTableThread) {
|
||||
mSymbolTableThread->Shutdown();
|
||||
}
|
||||
ResetGathering();
|
||||
}
|
||||
|
||||
nsresult nsProfiler::Init() {
|
||||
|
@ -143,10 +144,6 @@ nsProfiler::StartProfiler(uint32_t aEntries, double aInterval,
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsProfiler::StopProfiler() {
|
||||
// If we have a Promise in flight, we should reject it.
|
||||
if (mPromiseHolder.isSome()) {
|
||||
mPromiseHolder->RejectIfExists(NS_ERROR_DOM_ABORT_ERR, __func__);
|
||||
}
|
||||
ResetGathering();
|
||||
|
||||
profiler_stop();
|
||||
|
@ -921,7 +918,12 @@ void nsProfiler::FinishGathering() {
|
|||
}
|
||||
|
||||
void nsProfiler::ResetGathering() {
|
||||
mPromiseHolder.reset();
|
||||
// If we have an unfulfilled Promise in flight, we should reject it before
|
||||
// destroying the promise holder.
|
||||
if (mPromiseHolder.isSome()) {
|
||||
mPromiseHolder->RejectIfExists(NS_ERROR_DOM_ABORT_ERR, __func__);
|
||||
mPromiseHolder.reset();
|
||||
}
|
||||
mPendingProfiles = 0;
|
||||
mGathering = false;
|
||||
mWriter.reset();
|
||||
|
|
Загрузка…
Ссылка в новой задаче