Bug 1252382 - Get rid of PR_Sleep in the terminator;r=froydnj
authorDavid Rajchenbach-Teller <dteller@mozilla.com>
Tue, 01 Mar 2016 09:01:22 +0100
changeset 286294 e9a72b270abbe2e1b5181e352c56677019b918ee
parent 286293 f5e475aff6f0f527365894889421b79a4c5d1308
child 286295 af1b34021a320652d4b933d6d38a1d1153a9181d
push id30043
push userkwierso@gmail.com
push dateTue, 01 Mar 2016 23:22:33 +0000
treeherdermozilla-central@eb25b90a05c1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1252382
milestone47.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 1252382 - Get rid of PR_Sleep in the terminator;r=froydnj The terminator currently makes use of PR_Sleep. As it turns out, late in shutdown, this can cause infinite recursions and finally exit(-11) . This patch replaces PR_Sleep with usleep(3) and Sleep(). MozReview-Commit-ID: 3SybinpQUVl
toolkit/components/terminator/nsTerminator.cpp
--- a/toolkit/components/terminator/nsTerminator.cpp
+++ b/toolkit/components/terminator/nsTerminator.cpp
@@ -28,16 +28,22 @@
 #include "nsAppDirectoryServiceDefs.h"
 
 #include "nsIObserverService.h"
 #include "nsIPrefService.h"
 #if defined(MOZ_CRASHREPORTER)
 #include "nsExceptionHandler.h"
 #endif
 
+#if defined(XP_WIN)
+#include <windows.h>
+#else
+#include <unistd.h>
+#endif
+
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/MemoryChecking.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
 #include "mozilla/UniquePtr.h"
 #include "mozilla/unused.h"
@@ -122,29 +128,32 @@ RunWatchdog(void* arg)
 
   // Let's copy and deallocate options, that's one less leak to worry
   // about.
   UniquePtr<Options> options((Options*)arg);
   uint32_t crashAfterTicks = options->crashAfterTicks;
   options = nullptr;
 
   const uint32_t timeToLive = crashAfterTicks;
-  const PRIntervalTime ticksDuration = PR_MillisecondsToInterval(1000);
   while (true) {
     //
     // We do not want to sleep for the entire duration,
     // as putting the computer to sleep would suddenly
     // cause us to timeout on wakeup.
     //
     // Rather, we prefer sleeping for at most 1 second
     // at a time. If the computer sleeps then wakes up,
     // we have lost at most one second, which is much
     // more reasonable.
     //
-    PR_Sleep(ticksDuration);
+#if defined(XP_WIN)
+    Sleep(1000 /* ms */);
+#else
+    usleep(1000000 /* usec */);
+#endif
 
     if (gHeartbeat++ < timeToLive) {
       continue;
     }
 
     // Shutdown is apparently dead. Crash the process.
     MOZ_CRASH("Shutdown too long, probably frozen, causing a crash.");
   }