Bug 970904 - Fix PR_WaitCondVar timeout for sleep() in js shell. r=jandem
authorTooru Fujisawa <arai_a@mac.com>
Sat, 24 Jan 2015 21:21:25 +0900
changeset 225516 e4cea48ed2f5a3c23272d2693be6197c9480d750
parent 225515 42d4b2cb18b6567890c2113784761eb8f17337a1
child 225517 1cf171c1a17746ee518a39ab41864c8e29a43686
child 225547 88849e352ddcbca353ecf9ecc0c5222db5f56018
push id28163
push userphilringnalda@gmail.com
push dateSat, 24 Jan 2015 16:27:39 +0000
treeherdermozilla-central@1cf171c1a177 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs970904
milestone38.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 970904 - Fix PR_WaitCondVar timeout for sleep() in js shell. r=jandem
js/src/jit-test/tests/basic/sleep-without-timeout.js
js/src/shell/js.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/basic/sleep-without-timeout.js
@@ -0,0 +1,6 @@
+// sleep() should work without timeout() prior to it.
+
+sleep(0.001);
+sleep(0.01);
+sleep(0.1);
+sleep(1);
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -2895,25 +2895,26 @@ Sleep_fn(JSContext *cx, unsigned argc, V
         }
         t_ticks = (t_secs <= 0.0)
                   ? 0
                   : int64_t(PRMJ_USEC_PER_SEC * t_secs);
     }
     PR_Lock(gWatchdogLock);
     int64_t to_wakeup = PRMJ_Now() + t_ticks;
     for (;;) {
-        PR_WaitCondVar(gSleepWakeup, t_ticks);
+        PR_WaitCondVar(gSleepWakeup, PR_MillisecondsToInterval(t_ticks / 1000));
         if (gServiceInterrupt)
             break;
         int64_t now = PRMJ_Now();
         if (!IsBefore(now, to_wakeup))
             break;
         t_ticks = to_wakeup - now;
     }
     PR_Unlock(gWatchdogLock);
+    args.rval().setUndefined();
     return !gServiceInterrupt;
 }
 
 static bool
 InitWatchdog(JSRuntime *rt)
 {
     MOZ_ASSERT(!gWatchdogThread);
     gWatchdogLock = PR_NewLock();