Worker: Stop using WorkerThread::TerminateAllWorkersForTesting() in unit tests
TerminateAllWorkersForTesting() causes deadlock depending on timing. This CL replaces the function with a combination of TerminateForTesting() and WaitForShutdownForTesting() that are equivalent to TerminateAllWorkersForTesting() but don't acquire the lock. TerminateAllWorkersForTesting() on the main thread calls WaitableEvent::Wait() while that is holding the ThreadSetMutex(). The mutex is also referenced from the worker thread during worker startup in InitializeOnWorkerThread(). Deadlock happens when the main thread starts termination immediately before the worker thread tries to acquire the lock to insert itself in the thread set. Note: TerminateAllWorkersForTesting() is still used from LeakDetector. I'll try to remove/change it in a separate CL. Bug: 1003217 Change-Id: I7896057c1c65a830c621e120123558403a94c951 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1839224 Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org> Reviewed-by:Kenichi Ishibashi <bashi@chromium.org> Cr-Commit-Position: refs/heads/master@{#702767}
Showing
Please register or sign in to comment