Bug 1522246 - Shutdown workers immediately after terminate()ing them, r=asuth.
☠☠ backed out by 2ef9c49c8f27 ☠ ☠
authorBrian Hackett <bhackett1024@gmail.com>
Tue, 12 Feb 2019 14:11:59 -1000
changeset 519266 592350649c0fed65fde5d9056c0c550bb4f2af90
parent 519265 8fcd04c595a9b49eb779b978d4ebd4b7d2232761
child 519267 4e181eeea4794a15711bb254f06d2ff216b1bef1
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1522246
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1522246 - Shutdown workers immediately after terminate()ing them, r=asuth.
dom/workers/WorkerPrivate.cpp
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -2567,19 +2567,25 @@ void WorkerPrivate::DoRunLoop(JSContext*
   for (;;) {
     WorkerStatus currentStatus;
     bool debuggerRunnablesPending = false;
     bool normalRunnablesPending = false;
 
     {
       MutexAutoLock lock(mMutex);
 
+      // Wait for a runnable to arrive that we can execute, or for it to be okay
+      // to shutdown this worker once all holders have been removed.
+      // Holders may be removed from inside normal runnables, but we don't check
+      // for that after processing normal runnables, so we need to let control
+      // flow to the shutdown logic without blocking.
       while (mControlQueue.IsEmpty() &&
              !(debuggerRunnablesPending = !mDebuggerQueue.IsEmpty()) &&
-             !(normalRunnablesPending = NS_HasPendingEvents(mThread))) {
+             !(normalRunnablesPending = NS_HasPendingEvents(mThread)) &&
+             !(mStatus != Running && !HasActiveHolders())) {
         WaitForWorkerEvents();
       }
 
       auto result = ProcessAllControlRunnablesLocked();
       if (result != ProcessAllControlRunnablesResult::Nothing) {
         // NB: There's no JS on the stack here, so Abort vs MayContinue is
         // irrelevant