| Index: third_party/WebKit/Source/core/workers/WorkerThread.cpp
|
| diff --git a/third_party/WebKit/Source/core/workers/WorkerThread.cpp b/third_party/WebKit/Source/core/workers/WorkerThread.cpp
|
| index c862eb2915d0f5aec5188a86ed7df6ea9eb4089b..4c9fd41c6bf49d98dd87d6148515aaf77e919bc4 100644
|
| --- a/third_party/WebKit/Source/core/workers/WorkerThread.cpp
|
| +++ b/third_party/WebKit/Source/core/workers/WorkerThread.cpp
|
| @@ -351,6 +351,14 @@ void WorkerThread::terminateInternal(TerminationMode mode)
|
|
|
| // If terminate has already been called.
|
| if (m_terminated) {
|
| + if (m_runningDebuggerTask) {
|
| + // Any debugger task is guaranteed to finish, so we can wait for the
|
| + // completion even if the synchronous forcible termination is
|
| + // requested. Shutdown sequence will start after the task.
|
| + DCHECK(!m_scheduledForceTerminationTask);
|
| + return;
|
| + }
|
| +
|
| // The synchronous forcible termination request should overtake the
|
| // scheduled termination task because the request will block the main
|
| // thread and the scheduled termination task never runs.
|
| @@ -385,7 +393,7 @@ void WorkerThread::terminateInternal(TerminationMode mode)
|
| // loop. If script execution weren't forbidden, a while(1) loop in JS could
|
| // keep the thread alive forever.
|
| //
|
| - // (1) |m_readyToShutdown|: It this is set, the worker thread has already
|
| + // (1) |m_readyToShutdown|: If this is set, the worker thread has already
|
| // noticed that the thread is about to be terminated and the worker global
|
| // scope is already disposed, so we don't have to explicitly terminate the
|
| // worker execution.
|
| @@ -581,11 +589,13 @@ void WorkerThread::performDebuggerTaskOnWorkerThread(std::unique_ptr<CrossThread
|
| ThreadDebugger::idleStarted(isolate());
|
| {
|
| MutexLocker lock(m_threadStateMutex);
|
| - m_runningDebuggerTask = false;
|
| -
|
| - if (!m_terminated)
|
| + if (!m_terminated) {
|
| + m_runningDebuggerTask = false;
|
| return;
|
| + }
|
| // terminate() was called. Shutdown sequence will start soon.
|
| + // Keep |m_runningDebuggerTask| to prevent forcible termination from the
|
| + // main thread before shutdown preparation.
|
| }
|
| // Stop further worker tasks to run after this point.
|
| prepareForShutdownOnWorkerThread();
|
|
|