Skip to content

Commit

Permalink
Bug 1731564: Use motivated SpinEventLoopUntil inside storage/*. r=janv
Browse files Browse the repository at this point in the history
Depends on D127232

Differential Revision: https://phabricator.services.mozilla.com/D127233
  • Loading branch information
jensstutte committed Oct 7, 2021
1 parent 4320224 commit 1a837fb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
4 changes: 3 additions & 1 deletion storage/mozStorageConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,9 @@ Connection::SpinningSynchronousClose() {
RefPtr<CloseListener> listener = new CloseListener();
rv = AsyncClose(listener);
NS_ENSURE_SUCCESS(rv, rv);
MOZ_ALWAYS_TRUE(SpinEventLoopUntil([&]() { return listener->mClosed; }));
MOZ_ALWAYS_TRUE(
SpinEventLoopUntil("storage::Connection::SpinningSynchronousClose"_ns,
[&]() { return listener->mClosed; }));
MOZ_ASSERT(isClosed(), "The connection should be closed at this point");

return rv;
Expand Down
24 changes: 13 additions & 11 deletions storage/mozStorageService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -701,17 +701,19 @@ Service::Observe(nsISupports*, const char* aTopic, const char16_t*) {
(void)os->RemoveObserver(this, sObserverTopics[i]);
}

SpinEventLoopUntil([&]() -> bool {
// We must wait until all the closing connections are closed.
nsTArray<RefPtr<Connection>> connections;
getConnections(connections);
for (auto& conn : connections) {
if (conn->isClosing()) {
return false;
}
}
return true;
});
SpinEventLoopUntil("storage::Service::Observe(xpcom-shutdown-threads)"_ns,
[&]() -> bool {
// We must wait until all the closing connections are
// closed.
nsTArray<RefPtr<Connection>> connections;
getConnections(connections);
for (auto& conn : connections) {
if (conn->isClosing()) {
return false;
}
}
return true;
});

#ifdef DEBUG
nsTArray<RefPtr<Connection>> connections;
Expand Down

0 comments on commit 1a837fb

Please sign in to comment.