Bug 1458970 Avoid accessing mClientSource when a worker is Terminating in more places. r=baku

This commit is contained in:
Ben Kelly 2018-05-04 06:35:36 -07:00
Родитель 2e65d96a69
Коммит c6174cef5a
2 изменённых файлов: 15 добавлений и 3 удалений

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

@ -3526,9 +3526,15 @@ WorkerPrivate::GetClientState() const
}
const Maybe<ServiceWorkerDescriptor>
WorkerPrivate::GetController() const
WorkerPrivate::GetController()
{
AssertIsOnWorkerThread();
{
MutexAutoLock lock(mMutex);
if (mStatus >= Terminating) {
return Maybe<ServiceWorkerDescriptor>();
}
}
MOZ_DIAGNOSTIC_ASSERT(mClientSource);
return mClientSource->GetController();
}
@ -3537,9 +3543,15 @@ void
WorkerPrivate::Control(const ServiceWorkerDescriptor& aServiceWorker)
{
AssertIsOnWorkerThread();
MOZ_DIAGNOSTIC_ASSERT(mClientSource);
MOZ_DIAGNOSTIC_ASSERT(!IsChromeWorker());
MOZ_DIAGNOSTIC_ASSERT(Type() != WorkerTypeService);
{
MutexAutoLock lock(mMutex);
if (mStatus >= Terminating) {
return;
}
}
MOZ_DIAGNOSTIC_ASSERT(mClientSource);
mClientSource->SetController(aServiceWorker);
}

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

@ -560,7 +560,7 @@ public:
GetClientState() const;
const Maybe<ServiceWorkerDescriptor>
GetController() const;
GetController();
void
Control(const ServiceWorkerDescriptor& aServiceWorker);