Make the progress logic that triggers timeouts smarter.

This commit is contained in:
JoelKatz
2013-08-18 21:31:09 -07:00
parent 4e19c7cda1
commit 54a6d21903
2 changed files with 5 additions and 9 deletions

View File

@@ -12,12 +12,11 @@ PeerSet::PeerSet (uint256 const& hash, int interval, bool txnData)
, mTimeouts (0)
, mComplete (false)
, mFailed (false)
, mProgress (true)
, mAggressive (false)
, mTxnData (txnData)
, mTimer (getApp().getIOService ())
{
mLastAction = UptimeTimer::getInstance ().getElapsedSeconds ();
mLastAction = mLastProgress = UptimeTimer::getInstance ().getElapsedSeconds ();
assert ((mTimerInterval > 10) && (mTimerInterval < 30000));
}
@@ -51,17 +50,14 @@ void PeerSet::invokeOnTimer ()
if (isDone ())
return;
if (!mProgress)
if (!isProgress())
{
++mTimeouts;
WriteLog (lsWARNING, InboundLedger) << "Timeout(" << mTimeouts << ") pc=" << mPeers.size () << " acquiring " << mHash;
onTimer (false, sl);
}
else
{
mProgress = false;
onTimer (true, sl);
}
if (!isDone ())
setTimer ();

View File

@@ -34,12 +34,12 @@ public:
bool isActive ();
void progress ()
{
mProgress = true;
mLastProgress = UptimeTimer::getInstance().getElapsedSeconds();
mAggressive = false;
}
bool isProgress ()
{
return mProgress;
return (mLastProgress + (mTimerInterval / 1000)) > UptimeTimer::getInstance().getElapsedSeconds();
}
void touch ()
{
@@ -93,10 +93,10 @@ protected:
int mTimeouts;
bool mComplete;
bool mFailed;
bool mProgress;
bool mAggressive;
bool mTxnData;
int mLastAction;
int mLastProgress;
boost::recursive_mutex mLock;