зеркало из https://github.com/mozilla/gecko-dev.git
Bug 886791 - Deadlock can occur if nsThreadPool::Dispatch() is called under lock, r=bsmedberg
This commit is contained in:
Родитель
3efaff8e99
Коммит
0f41803005
|
@ -100,7 +100,15 @@ nsThreadPool::PutEvent(nsIRunnable *event)
|
|||
}
|
||||
LOG(("THRD-P(%p) put [%p kill=%d]\n", this, thread.get(), killThread));
|
||||
if (killThread) {
|
||||
thread->Shutdown();
|
||||
// Pending events are processed on the current thread during
|
||||
// nsIThread::Shutdown() execution, so if nsThreadPool::Dispatch() is called
|
||||
// under caller's lock then deadlock could occur. This happens e.g. in case
|
||||
// of nsStreamCopier. To prevent this situation, dispatch a shutdown event
|
||||
// to the current thread instead of calling nsIThread::Shutdown() directly.
|
||||
|
||||
nsRefPtr<nsIRunnable> r = NS_NewRunnableMethod(thread,
|
||||
&nsIThread::Shutdown);
|
||||
NS_DispatchToCurrentThread(r);
|
||||
} else {
|
||||
thread->Dispatch(this, NS_DISPATCH_NORMAL);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче