Bug 1443688 - Ensure NotifyWait doesn't result in indefinite hangs r=mystor
authorDoug Thayer <dothayer@mozilla.com>
Sun, 18 Mar 2018 09:28:17 -0700
changeset 408804 ae5f0713084e4dbcd1ffd0bd568b77f3cffd0290
parent 408803 f334c282d6fa25de9a415b560bd8474e518cdd60
child 408805 49d1cb161b40922d872836674ec92d0b7a8aa7b0
push id33662
push userapavel@mozilla.com
push dateMon, 19 Mar 2018 22:39:10 +0000
treeherdermozilla-central@48f43d2ad95e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmystor
bugs1443688
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 1443688 - Ensure NotifyWait doesn't result in indefinite hangs r=mystor If we enter a hang through the normal timed loop of RunMonitorThread, and then call NotifyWait, it will result in a hang with an indefinite duration being reported once NotifyActivity is called again. MozReview-Commit-ID: 4vUip65L0qo
toolkit/components/backgroundhangmonitor/BackgroundHangMonitor.cpp
--- a/toolkit/components/backgroundhangmonitor/BackgroundHangMonitor.cpp
+++ b/toolkit/components/backgroundhangmonitor/BackgroundHangMonitor.cpp
@@ -231,16 +231,23 @@ public:
   {
     MonitorAutoLock autoLock(mManager->mLock);
 
     if (mWaiting) {
       return;
     }
 
     Update();
+    if (mHanging) {
+      // We were hanging! We're done with that now, so let's report it.
+      // ReportHang() doesn't do much work on the current thread, and is
+      // safe to call from any thread as long as we're holding the lock.
+      ReportHang(mInterval - mHangStart);
+      mHanging = false;
+    }
     mWaiting = true;
   }
 
   // Returns true if this thread is (or might be) shared between other
   // BackgroundHangMonitors for the monitored thread.
   bool IsShared() {
     return mThreadType == BackgroundHangMonitor::THREAD_SHARED;
   }