Bug 1239288 - Fix a race in the win32 job scheduler's shutdown. r=jrmuizel

This commit is contained in:
Nicolas Silva 2016-01-19 09:48:51 +01:00
Родитель 42b3ccc897
Коммит 59f28c22d9
1 изменённых файлов: 7 добавлений и 2 удалений

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

@ -132,9 +132,14 @@ MultiThreadedJobQueue::RegisterThread()
void
MultiThreadedJobQueue::UnregisterThread()
{
CriticalSectionAutoEnter lock(&mSection);
mSection.Enter();
mThreadsCount -= 1;
if (mThreadsCount == 0) {
bool finishShutdown = mThreadsCount == 0;
mSection.Leave();
if (finishShutdown) {
// Can't touch mSection or any other member from now on because this object
// may get deleted on the main thread after mShutdownEvent is set.
::SetEvent(mShutdownEvent);
}
}