Bug 1155059: Patch 8 - Don't leak runnables when MediaCache/FileBlockCache get shut down after XPCOM is in final shutdown r=cpearce

This commit is contained in:
Randell Jesup 2015-07-09 23:21:46 -04:00
Родитель 5211d5e9ad
Коммит d6a4cd77f2
2 изменённых файлов: 18 добавлений и 5 удалений

Просмотреть файл

@ -74,9 +74,16 @@ void FileBlockCache::Close()
// opening more streams, while the media cache is shutting down and
// releasing memory etc! Also note we close mFD in the destructor so
// as to not disturb any IO that's currently running.
nsCOMPtr<nsIRunnable> event = new ShutdownThreadEvent(mThread);
mThread = nullptr;
NS_DispatchToMainThread(event);
nsCOMPtr<nsIThread> mainThread = do_GetMainThread();
if (mainThread) {
nsCOMPtr<nsIRunnable> event = new ShutdownThreadEvent(mThread);
mainThread->Dispatch(event.forget(), NS_DISPATCH_NORMAL);
} else {
// we're on Mainthread already, *and* the event queues are already
// shut down, so no events should occur - certainly not creations of
// new streams.
mThread->Shutdown();
}
}
}

Просмотреть файл

@ -1409,8 +1409,14 @@ MediaCache::QueueUpdate()
if (mUpdateQueued)
return;
mUpdateQueued = true;
nsCOMPtr<nsIRunnable> event = new UpdateEvent();
NS_DispatchToMainThread(event);
// XXX MediaCache does updates when decoders are still running at
// shutdown and get freed in the final cycle-collector cleanup. So
// don't leak a runnable in that case.
nsCOMPtr<nsIThread> mainThread = do_GetMainThread();
if (mainThread) {
nsCOMPtr<nsIRunnable> event = new UpdateEvent();
mainThread->Dispatch(event.forget(), NS_DISPATCH_NORMAL);
}
}
void