зеркало из https://github.com/mozilla/gecko-dev.git
Bug 679240 - Split total channel timeout into two discrete wait periods. Avoids aborting children after system sleep. r=bsmedberg
This commit is contained in:
Родитель
b79f6456f0
Коммит
5fc873d79e
|
@ -62,6 +62,7 @@ SyncChannel::SyncChannel(SyncListener* aListener)
|
|||
, mProcessingSyncMessage(false)
|
||||
, mNextSeqno(0)
|
||||
, mTimeoutMs(kNoTimeout)
|
||||
, mInTimeoutSecondHalf(false)
|
||||
#ifdef OS_WIN
|
||||
, mTopFrame(NULL)
|
||||
#endif
|
||||
|
@ -283,6 +284,23 @@ SyncChannel::ShouldContinueFromTimeout()
|
|||
return cont;
|
||||
}
|
||||
|
||||
bool
|
||||
SyncChannel::WaitResponse(bool aWaitTimedOut)
|
||||
{
|
||||
if (aWaitTimedOut) {
|
||||
if (mInTimeoutSecondHalf) {
|
||||
// We've really timed out this time
|
||||
return false;
|
||||
}
|
||||
// Try a second time
|
||||
mInTimeoutSecondHalf = true;
|
||||
} else {
|
||||
mInTimeoutSecondHalf = false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Windows versions of the following two functions live in
|
||||
// WindowsMessageLoop.cpp.
|
||||
|
||||
|
@ -301,7 +319,7 @@ SyncChannel::WaitForNotify()
|
|||
|
||||
// if the timeout didn't expire, we know we received an event.
|
||||
// The converse is not true.
|
||||
return !IsTimeoutExpired(waitStart, timeout);
|
||||
return WaitResponse(IsTimeoutExpired(waitStart, timeout));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -81,9 +81,13 @@ public:
|
|||
// Synchronously send |msg| (i.e., wait for |reply|)
|
||||
virtual bool Send(Message* msg, Message* reply);
|
||||
|
||||
// Set channel timeout value. Since this is broken up into
|
||||
// two period, the minimum timeout value is 2ms.
|
||||
void SetReplyTimeoutMs(int32 aTimeoutMs) {
|
||||
AssertWorkerThread();
|
||||
mTimeoutMs = (aTimeoutMs <= 0) ? kNoTimeout : aTimeoutMs;
|
||||
mTimeoutMs = (aTimeoutMs <= 0) ? kNoTimeout :
|
||||
// timeouts are broken up into two periods
|
||||
(int32)ceil((double)aTimeoutMs/2.0);
|
||||
}
|
||||
|
||||
static bool IsPumpingMessages() {
|
||||
|
@ -185,6 +189,12 @@ protected:
|
|||
|
||||
static bool sIsPumpingMessages;
|
||||
|
||||
// Timeout periods are broken up in two to prevent system suspension from
|
||||
// triggering an abort. This method (called by WaitForNotify with a 'did
|
||||
// timeout' flag) decides if we should wait again for half of mTimeoutMs
|
||||
// or give up.
|
||||
bool WaitResponse(bool aWaitTimedOut);
|
||||
bool mInTimeoutSecondHalf;
|
||||
int32 mTimeoutMs;
|
||||
|
||||
#ifdef OS_WIN
|
||||
|
|
|
@ -741,7 +741,7 @@ SyncChannel::WaitForNotify()
|
|||
|
||||
MonitorAutoUnlock unlock(*mMonitor);
|
||||
|
||||
bool retval = true;
|
||||
bool timedout = false;
|
||||
|
||||
UINT_PTR timerId = NULL;
|
||||
TimeoutData timeoutData = { 0 };
|
||||
|
@ -795,7 +795,7 @@ SyncChannel::WaitForNotify()
|
|||
|
||||
if (TimeoutHasExpired(timeoutData)) {
|
||||
// A timeout was specified and we've passed it. Break out.
|
||||
retval = false;
|
||||
timedout = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -847,7 +847,7 @@ SyncChannel::WaitForNotify()
|
|||
|
||||
SyncChannel::SetIsPumpingMessages(false);
|
||||
|
||||
return retval;
|
||||
return WaitResponse(timedout);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -868,7 +868,7 @@ RPCChannel::WaitForNotify()
|
|||
|
||||
MonitorAutoUnlock unlock(*mMonitor);
|
||||
|
||||
bool retval = true;
|
||||
bool timedout = false;
|
||||
|
||||
UINT_PTR timerId = NULL;
|
||||
TimeoutData timeoutData = { 0 };
|
||||
|
@ -949,7 +949,7 @@ RPCChannel::WaitForNotify()
|
|||
|
||||
if (TimeoutHasExpired(timeoutData)) {
|
||||
// A timeout was specified and we've passed it. Break out.
|
||||
retval = false;
|
||||
timedout = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -987,7 +987,7 @@ RPCChannel::WaitForNotify()
|
|||
|
||||
SyncChannel::SetIsPumpingMessages(false);
|
||||
|
||||
return retval;
|
||||
return WaitResponse(timedout);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -73,7 +73,7 @@ TestHangsParent::ShouldContinueFromReplyTimeout()
|
|||
{
|
||||
mDetectedHang = true;
|
||||
|
||||
// so we've detected a timeout after 1 ms ... now we cheat and
|
||||
// so we've detected a timeout after 2 ms ... now we cheat and
|
||||
// sleep for a long time, to allow the subprocess's reply to come
|
||||
// in
|
||||
|
||||
|
@ -95,9 +95,9 @@ TestHangsParent::AnswerStackFrame()
|
|||
fail("should have timed out!");
|
||||
}
|
||||
else {
|
||||
// minimum possible, 1 ms. We want to detecting a hang to race
|
||||
// minimum possible, 2 ms. We want to detecting a hang to race
|
||||
// with the reply coming in, as reliably as possible
|
||||
SetReplyTimeoutMs(1);
|
||||
SetReplyTimeoutMs(2);
|
||||
|
||||
if (CallHang())
|
||||
fail("should have timed out!");
|
||||
|
|
Загрузка…
Ссылка в новой задаче