Bug 1546576 - Canceling workers during xpcom-shutdown, r=asuth
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 24 Apr 2019 17:18:29 +0000
changeset 530070 451c85dbd5720dc49cbf6129151af789b37a5f30
parent 530069 447b0f5a5802dd6b352ddae1d8e0b8c0430ce2fd
child 530071 11de829f1358ba2c52b83925701a8ef8ba2523bc
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1546576
milestone68.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 1546576 - Canceling workers during xpcom-shutdown, r=asuth Differential Revision: https://phabricator.services.mozilla.com/D28595
dom/workers/RuntimeService.cpp
dom/workers/WorkerPrivate.cpp
dom/workers/WorkerPrivate.h
--- a/dom/workers/RuntimeService.cpp
+++ b/dom/workers/RuntimeService.cpp
@@ -1663,17 +1663,17 @@ void RuntimeService::Shutdown() {
     AddAllTopLevelWorkersToArray(workers);
 
     if (!workers.IsEmpty()) {
       // Cancel all top-level workers.
       {
         MutexAutoUnlock unlock(mMutex);
 
         for (uint32_t index = 0; index < workers.Length(); index++) {
-          if (!workers[index]->Kill()) {
+          if (!workers[index]->Cancel()) {
             NS_WARNING("Failed to cancel worker!");
           }
         }
       }
     }
   }
 }
 
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -3940,16 +3940,18 @@ bool WorkerPrivate::NotifyInternal(Worke
   WorkerStatus previousStatus;
   {
     MutexAutoLock lock(mMutex);
 
     if (mStatus >= aStatus) {
       return true;
     }
 
+    MOZ_ASSERT_IF(aStatus == Killing, mStatus == Canceling);
+
     if (aStatus >= Canceling) {
       MutexAutoUnlock unlock(mMutex);
       data->mClientSource.reset();
       if (data->mScope) {
         data->mScope->NoteTerminating();
       }
     }
 
--- a/dom/workers/WorkerPrivate.h
+++ b/dom/workers/WorkerPrivate.h
@@ -128,18 +128,16 @@ class WorkerPrivate : public RelativeTim
   // May be called on any thread...
   bool Start();
 
   // Called on the parent thread.
   bool Notify(WorkerStatus aStatus);
 
   bool Cancel() { return Notify(Canceling); }
 
-  bool Kill() { return Notify(Killing); }
-
   bool Close();
 
   // The passed principal must be the Worker principal in case of a
   // ServiceWorker and the loading principal for any other type.
   static void OverrideLoadInfoLoadGroup(WorkerLoadInfo& aLoadInfo,
                                         nsIPrincipal* aPrincipal);
 
   bool IsDebuggerRegistered() {