Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(803)

Unified Diff: Source/core/workers/WorkerThread.cpp

Issue 1184833002: Fix a race condition during worker thread initialization (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: AnyNumber => AtMost Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/core/workers/WorkerThreadTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/workers/WorkerThread.cpp
diff --git a/Source/core/workers/WorkerThread.cpp b/Source/core/workers/WorkerThread.cpp
index ee06a089949d8c1f193bb1558b17f2e439fa86d6..3ad4b90fe2331889564bd17a21417ed203ae2d49 100644
--- a/Source/core/workers/WorkerThread.cpp
+++ b/Source/core/workers/WorkerThread.cpp
@@ -214,6 +214,8 @@ void WorkerThread::initialize(PassOwnPtr<WorkerThreadStartupData> startupData)
// Notify the proxy that the WorkerGlobalScope has been disposed of.
// This can free this thread object, hence it must not be touched afterwards.
m_workerReportingProxy.workerThreadTerminated();
+ // Notify the main thread that it is safe to deallocate our resources.
+ m_terminationEvent->signal();
return;
}
@@ -323,11 +325,11 @@ void WorkerThread::terminateInternal()
if (m_shutdown)
return;
- // If the worker thread was never initialized, complete the termination immediately.
- if (!m_workerGlobalScope) {
- m_terminationEvent->signal();
+ // If the worker thread was never initialized, don't start another
+ // shutdown, but still wait for the thread to signal when termination has
+ // completed.
+ if (!m_workerGlobalScope)
return;
- }
// Ensure that tasks are being handled by thread event loop. If script execution weren't forbidden, a while(1) loop in JS could keep the thread alive forever.
m_workerGlobalScope->script()->willScheduleExecutionTermination();
« no previous file with comments | « no previous file | Source/core/workers/WorkerThreadTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698