Bug 1700676 - Unregister the lock itself before unblock other locks; r=dom-storage-reviewers,sg,janv

Differential Revision: https://phabricator.services.mozilla.com/D109640
This commit is contained in:
Tom Tung 2021-04-16 01:09:11 +00:00
parent 1631cf13b6
commit be03b11109

View File

@ -45,17 +45,25 @@ DirectoryLockImpl::DirectoryLockImpl(
DirectoryLockImpl::~DirectoryLockImpl() {
AssertIsOnOwningThread();
for (NotNull<RefPtr<DirectoryLockImpl>> blockingLock : mBlocking) {
blockingLock->MaybeUnblock(*this);
}
mBlocking.Clear();
// We must call UnregisterDirectoryLock before unblocking other locks because
// UnregisterDirectoryLock also updates the origin last access time and the
// access flag (if the last lock for given origin is unregistered). One of the
// blocked locks could be requested by the clear/reset operation which stores
// cached information about origins in storage.sqlite. So if the access flag
// is not updated before unblocking the lock for reset/clear, we might store
// invalid information which can lead to omitting origin initialization during
// next temporary storage initialization.
if (mRegistered) {
mQuotaManager->UnregisterDirectoryLock(*this);
}
MOZ_ASSERT(!mRegistered);
for (NotNull<RefPtr<DirectoryLockImpl>> blockingLock : mBlocking) {
blockingLock->MaybeUnblock(*this);
}
mBlocking.Clear();
}
#ifdef DEBUG