Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit ed48987

Browse files
committed
Bug 1950564 - QM: Ensure shutdown waits for initialization of all temporary origins to finish; r=dom-storage-reviewers,jstutte
When incremental origin initialization is enabled, shutdown handling in the quota manager needed improvements to ensure a clean and reliable shutdown process. Previously, shutdown could proceed too far while initialization of all temporary origins in the background was still in progress, potentially leading to inconsistent states, such as the quota manager joining the QM IO thread while the initialization was ongoing. To address this, the existing boolean flag for ongoing initialization is used to prevent premature shutdown steps while the initialization is still active. Differential Revision: https://phabricator.services.mozilla.com/D239852
1 parent 85015a4 commit ed48987

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

dom/quota/ActorsParent.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2520,18 +2520,23 @@ void QuotaManager::Shutdown() {
25202520
// `isAllClientsShutdownComplete` calls because it should be sufficient
25212521
// to rely on `ShutdownStorage` to abort all existing operations and to
25222522
// wait for all existing directory locks to be released as well.
2523+
//
2524+
// This might not be possible after adding mInitializingAllTemporaryOrigins
2525+
// to the checks below.
25232526

2524-
const bool needsToWait =
2525-
initiateShutdownWorkThreads() || static_cast<bool>(gNormalOriginOps);
2527+
const bool needsToWait = initiateShutdownWorkThreads() ||
2528+
static_cast<bool>(gNormalOriginOps) ||
2529+
mInitializingAllTemporaryOrigins;
25262530

25272531
// If any clients cannot shutdown immediately, spin the event loop while we
25282532
// wait on all the threads to close.
25292533
if (needsToWait) {
25302534
startKillActorsTimer();
25312535

25322536
MOZ_ALWAYS_TRUE(SpinEventLoopUntil(
2533-
"QuotaManager::Shutdown"_ns, [isAllClientsShutdownComplete]() {
2534-
return !gNormalOriginOps && isAllClientsShutdownComplete();
2537+
"QuotaManager::Shutdown"_ns, [this, isAllClientsShutdownComplete]() {
2538+
return !gNormalOriginOps && isAllClientsShutdownComplete() &&
2539+
!mInitializingAllTemporaryOrigins;
25352540
}));
25362541

25372542
stopKillActorsTimer();

dom/quota/test/xpcshell/test_shutdownDuringAllTemporaryOriginsInitialization2.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ async function testSteps() {
167167
["dom.quotaManager.loadQuotaFromCache", false],
168168
["dom.quotaManager.groupInitialization.pauseOnIOThreadMs", 2000],
169169
],
170-
skip_if: () => true,
171170
},
172171
testShutdownDuringAllTemporaryOriginsInitialization2
173172
);

0 commit comments

Comments
 (0)