mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Bug 1411908 - Part 1: Wait for all live database objects to finish when shutting down; r=asuth
This commit is contained in:
parent
e223d1147b
commit
ba5642c8cd
@ -6349,7 +6349,6 @@ private:
|
||||
bool mInvalidated;
|
||||
bool mActorWasAlive;
|
||||
bool mActorDestroyed;
|
||||
bool mMetadataCleanedUp;
|
||||
#ifdef DEBUG
|
||||
bool mAllBlobsUnmapped;
|
||||
#endif
|
||||
@ -13868,7 +13867,6 @@ Database::Database(Factory* aFactory,
|
||||
, mInvalidated(false)
|
||||
, mActorWasAlive(false)
|
||||
, mActorDestroyed(false)
|
||||
, mMetadataCleanedUp(false)
|
||||
#ifdef DEBUG
|
||||
, mAllBlobsUnmapped(false)
|
||||
#endif
|
||||
@ -13981,8 +13979,6 @@ Database::Invalidate()
|
||||
}
|
||||
|
||||
MOZ_ALWAYS_TRUE(CloseInternal());
|
||||
|
||||
CleanupMetadata();
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -14248,22 +14244,18 @@ Database::CleanupMetadata()
|
||||
{
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
if (!mMetadataCleanedUp) {
|
||||
mMetadataCleanedUp = true;
|
||||
DatabaseActorInfo* info;
|
||||
MOZ_ALWAYS_TRUE(gLiveDatabaseHashtable->Get(Id(), &info));
|
||||
MOZ_ALWAYS_TRUE(info->mLiveDatabases.RemoveElement(this));
|
||||
|
||||
DatabaseActorInfo* info;
|
||||
MOZ_ALWAYS_TRUE(gLiveDatabaseHashtable->Get(Id(), &info));
|
||||
MOZ_ALWAYS_TRUE(info->mLiveDatabases.RemoveElement(this));
|
||||
|
||||
if (info->mLiveDatabases.IsEmpty()) {
|
||||
MOZ_ASSERT(!info->mWaitingFactoryOp ||
|
||||
!info->mWaitingFactoryOp->HasBlockedDatabases());
|
||||
gLiveDatabaseHashtable->Remove(Id());
|
||||
}
|
||||
|
||||
// Match the IncreaseBusyCount in OpenDatabaseOp::EnsureDatabaseActor().
|
||||
DecreaseBusyCount();
|
||||
if (info->mLiveDatabases.IsEmpty()) {
|
||||
MOZ_ASSERT(!info->mWaitingFactoryOp ||
|
||||
!info->mWaitingFactoryOp->HasBlockedDatabases());
|
||||
gLiveDatabaseHashtable->Remove(Id());
|
||||
}
|
||||
|
||||
// Match the IncreaseBusyCount in OpenDatabaseOp::EnsureDatabaseActor().
|
||||
DecreaseBusyCount();
|
||||
}
|
||||
|
||||
bool
|
||||
@ -17888,22 +17880,15 @@ QuotaClient::ShutdownWorkThreads()
|
||||
|
||||
mShutdownRequested = true;
|
||||
|
||||
// Shutdown maintenance thread pool (this spins the event loop until all
|
||||
// threads are gone). This should release any maintenance related quota
|
||||
// objects.
|
||||
if (mMaintenanceThreadPool) {
|
||||
mMaintenanceThreadPool->Shutdown();
|
||||
mMaintenanceThreadPool = nullptr;
|
||||
}
|
||||
AbortOperations(VoidCString());
|
||||
|
||||
// Let any runnables dispatched from dying maintenance threads to be
|
||||
// processed. This should release any maintenance related directory locks.
|
||||
if (mCurrentMaintenance) {
|
||||
MOZ_ALWAYS_TRUE(SpinEventLoopUntil([&]() {
|
||||
return !mCurrentMaintenance;
|
||||
}));
|
||||
}
|
||||
// This should release any IDB related quota objects or directory locks.
|
||||
MOZ_ALWAYS_TRUE(SpinEventLoopUntil([&]() {
|
||||
return (!gLiveDatabaseHashtable || !gLiveDatabaseHashtable->Count()) &&
|
||||
!mCurrentMaintenance;
|
||||
}));
|
||||
|
||||
// And finally, shutdown all threads.
|
||||
RefPtr<ConnectionPool> connectionPool = gConnectionPool.get();
|
||||
if (connectionPool) {
|
||||
connectionPool->Shutdown();
|
||||
@ -17918,6 +17903,11 @@ QuotaClient::ShutdownWorkThreads()
|
||||
|
||||
gFileHandleThreadPool = nullptr;
|
||||
}
|
||||
|
||||
if (mMaintenanceThreadPool) {
|
||||
mMaintenanceThreadPool->Shutdown();
|
||||
mMaintenanceThreadPool = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -84,10 +84,14 @@ function* testSteps()
|
||||
request.onsuccess = grabEventAndContinueHandler;
|
||||
event = yield undefined;
|
||||
|
||||
is(event.type, "upgradeneeded", "Got correct event type");
|
||||
|
||||
db = event.target.result;
|
||||
db.onerror = errorHandler;
|
||||
|
||||
is(event.type, "upgradeneeded", "Got correct event type");
|
||||
event = yield undefined;
|
||||
|
||||
is(event.type, "success", "Got correct event type");
|
||||
|
||||
is(db.name, name, "Correct name");
|
||||
is(db.version, version, "Correct version");
|
||||
|
Loading…
Reference in New Issue
Block a user