Bug 1457187 P2 Call NoteTerminating() from WorkerPrivate::NotifyInternal(). r=baku
authorBen Kelly <ben@wanderview.com>
Thu, 26 Apr 2018 09:18:01 -0700
changeset 471931 4446fa7a754f1283e4a26124a507b648ec0e0a01
parent 471930 184cbe8d02d950ffd9b678f0349c796f2e9170f9
child 471932 583940ed5be79dbc03ff7d148194ce28fc5eedd4
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1457187
milestone61.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 1457187 P2 Call NoteTerminating() from WorkerPrivate::NotifyInternal(). r=baku
dom/workers/WorkerPrivate.cpp
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -3253,22 +3253,16 @@ WorkerPrivate::DoRunLoop(JSContext* aCx)
         // The state of the world may have changed, recheck it.
         normalRunnablesPending = NS_HasPendingEvents(mThread);
         // The debugger queue doesn't get cleared, so we can ignore that.
       }
 
       currentStatus = mStatus;
     }
 
-    if (currentStatus >= Terminating && previousStatus < Terminating) {
-      if (mScope) {
-        mScope->NoteTerminating();
-      }
-    }
-
     // if all holders are done then we can kill this thread.
     if (currentStatus != Running && !HasActiveHolders()) {
 
       // If we just changed status, we must schedule the current runnables.
       if (previousStatus != Running && currentStatus != Killing) {
         NotifyInternal(Killing);
 
 #ifdef DEBUG
@@ -4514,16 +4508,23 @@ WorkerPrivate::NotifyInternal(WorkerStat
   WorkerStatus previousStatus;
   {
     MutexAutoLock lock(mMutex);
 
     if (mStatus >= aStatus) {
       return true;
     }
 
+    if (aStatus >= Terminating) {
+      if (mScope) {
+        MutexAutoUnlock unlock(mMutex);
+        mScope->NoteTerminating();
+      }
+    }
+
     // Make sure the hybrid event target stops dispatching runnables
     // once we reaching the killing state.
     if (aStatus == Killing) {
       // To avoid deadlock we always acquire the event target mutex before the
       // worker private mutex.  (We do it in this order because this is what
       // workers best for event dispatching.)  To enforce that order here we
       // need to unlock the worker private mutex before we lock the event target
       // mutex in ForgetWorkerPrivate.