Bug 1437167 - Part 3: Fix some platform-specific consumers of the Monitor::Wait APIs on a CLOSED TREE, a=bustage

MozReview-Commit-ID: FymGvwEtZRk
This commit is contained in:
Nika Layzell 2018-03-05 16:30:19 -05:00
parent 08e65e40ba
commit 801a4a8d1a
2 changed files with 6 additions and 19 deletions

View File

@ -846,13 +846,6 @@ MessageChannel::SpinInternalEventLoop()
} while (true);
}
static inline bool
IsTimeoutExpired(PRIntervalTime aStart, PRIntervalTime aTimeout)
{
return (aTimeout != PR_INTERVAL_NO_TIMEOUT) &&
(aTimeout <= (PR_IntervalNow() - aStart));
}
static HHOOK gWindowHook;
static inline void
@ -1030,27 +1023,21 @@ MessageChannel::WaitForSyncNotify(bool aHandleWindowsMessages)
// Use a blocking wait if this channel does not require
// Windows message deferral behavior.
if (!(mFlags & REQUIRE_DEFERRED_MESSAGE_PROTECTION) || !aHandleWindowsMessages) {
PRIntervalTime timeout = (kNoTimeout == mTimeoutMs) ?
PR_INTERVAL_NO_TIMEOUT :
PR_MillisecondsToInterval(mTimeoutMs);
PRIntervalTime waitStart = 0;
if (timeout != PR_INTERVAL_NO_TIMEOUT) {
waitStart = PR_IntervalNow();
}
TimeDuration timeout = (kNoTimeout == mTimeoutMs) ?
TimeDuration::Forever() :
TimeDuration::FromMilliseconds(mTimeoutMs);
MOZ_ASSERT(!mIsSyncWaitingOnNonMainThread);
mIsSyncWaitingOnNonMainThread = true;
mMonitor->Wait(timeout);
CVStatus status = mMonitor->Wait(timeout);
MOZ_ASSERT(mIsSyncWaitingOnNonMainThread);
mIsSyncWaitingOnNonMainThread = false;
// If the timeout didn't expire, we know we received an event. The
// converse is not true.
return WaitResponse(timeout == PR_INTERVAL_NO_TIMEOUT ?
false : IsTimeoutExpired(waitStart, timeout));
return WaitResponse(status == CVStaus::Timeout);
}
NS_ASSERTION(mFlags & REQUIRE_DEFERRED_MESSAGE_PROTECTION,

View File

@ -97,7 +97,7 @@ UpdateDriverSetupMacCommandLine(int& argc, char**& argv, bool restart)
// The length of this wait is arbitrary, but should be long enough that having
// it expire means something is seriously wrong.
rv = MonitorAutoLock(monitor).Wait(PR_SecondsToInterval(60));
rv = MonitorAutoLock(monitor).Wait(TimeDuration::FromSeconds(60));
if (NS_FAILED(rv)) {
LOG(("Update driver timed out waiting for SetupMacCommandLine: %d\n", rv));
}