From 54a6d219033b752dc69637f97ec41c4dc60050b1 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Sun, 18 Aug 2013 21:31:09 -0700 Subject: [PATCH] Make the progress logic that triggers timeouts smarter. --- modules/ripple_app/peers/ripple_PeerSet.cpp | 8 ++------ modules/ripple_app/peers/ripple_PeerSet.h | 6 +++--- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/modules/ripple_app/peers/ripple_PeerSet.cpp b/modules/ripple_app/peers/ripple_PeerSet.cpp index 3a278f814..15e9ef6ae 100644 --- a/modules/ripple_app/peers/ripple_PeerSet.cpp +++ b/modules/ripple_app/peers/ripple_PeerSet.cpp @@ -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 (); diff --git a/modules/ripple_app/peers/ripple_PeerSet.h b/modules/ripple_app/peers/ripple_PeerSet.h index 73e55e6a0..a7155d380 100644 --- a/modules/ripple_app/peers/ripple_PeerSet.h +++ b/modules/ripple_app/peers/ripple_PeerSet.h @@ -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;