Bug 842411 - Fire operation callback before time is up so we can test the non-aborting case (r=terrence)

--HG--
extra : rebase_source : 9f23aa8fc1be361f55b2db3943d20d510730fb7a
This commit is contained in:
Luke Wagner 2013-02-19 13:17:39 -08:00
parent bce0a6fdc3
commit b233d5c3ea

View File

@ -2840,26 +2840,34 @@ WatchdogMain(void *arg)
PR_Lock(gWatchdogLock);
while (gWatchdogThread) {
int64_t now = PRMJ_Now();
if (gWatchdogHasTimeout && !IsBefore(now, gWatchdogTimeout)) {
/*
* The timeout has just expired. Trigger the operation callback
* outside the lock.
*/
gWatchdogHasTimeout = false;
PR_Unlock(gWatchdogLock);
CancelExecution(rt);
PR_Lock(gWatchdogLock);
int64_t now = PRMJ_Now();
if (gWatchdogHasTimeout && !IsBefore(now, gWatchdogTimeout)) {
/*
* The timeout has just expired. Trigger the operation callback
* outside the lock.
*/
gWatchdogHasTimeout = false;
PR_Unlock(gWatchdogLock);
CancelExecution(rt);
PR_Lock(gWatchdogLock);
/* Wake up any threads doing sleep. */
PR_NotifyAllCondVar(gSleepWakeup);
/* Wake up any threads doing sleep. */
PR_NotifyAllCondVar(gSleepWakeup);
} else {
uint64_t sleepDuration = PR_INTERVAL_NO_TIMEOUT;
if (gWatchdogHasTimeout)
sleepDuration = (gWatchdogTimeout - now) / PRMJ_USEC_PER_SEC * PR_TicksPerSecond();
mozilla::DebugOnly<PRStatus> status =
PR_WaitCondVar(gWatchdogWakeup, sleepDuration);
JS_ASSERT(status == PR_SUCCESS);
if (gWatchdogHasTimeout) {
/*
* Time hasn't expired yet. Simulate an operation callback
* which doesn't abort execution.
*/
JS_TriggerOperationCallback(rt);
}
uint64_t sleepDuration = PR_INTERVAL_NO_TIMEOUT;
if (gWatchdogHasTimeout)
sleepDuration = PR_TicksPerSecond() / 10;
mozilla::DebugOnly<PRStatus> status =
PR_WaitCondVar(gWatchdogWakeup, sleepDuration);
JS_ASSERT(status == PR_SUCCESS);
}
}
PR_Unlock(gWatchdogLock);