mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-03 01:15:53 +00:00
If we start seeing acquire timeouts, don't start new acquires.
The link could be overloaded.
This commit is contained in:
@@ -920,15 +920,21 @@ void LedgerAcquireMaster::sweep()
|
||||
}
|
||||
}
|
||||
|
||||
int LedgerAcquireMaster::getFetchCount()
|
||||
int LedgerAcquireMaster::getFetchCount(int& timeoutCount)
|
||||
{
|
||||
timeoutCount = 0;
|
||||
int ret = 0;
|
||||
{
|
||||
typedef std::pair<uint256, LedgerAcquire::pointer> u256_acq_pair;
|
||||
boost::mutex::scoped_lock sl(mLock);
|
||||
BOOST_FOREACH(const u256_acq_pair& it, mLedgers)
|
||||
{
|
||||
if (it.second->isActive())
|
||||
{
|
||||
++ret;
|
||||
timeoutCount += it.second->getTimeouts();
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ public:
|
||||
void dropLedger(const uint256& ledgerHash);
|
||||
SMAddNode gotLedgerData(ripple::TMLedgerData& packet, Peer::ref);
|
||||
|
||||
int getFetchCount();
|
||||
int getFetchCount(int& timeoutCount);
|
||||
void logFailure(const uint256& h) { mRecentFailures.add(h); }
|
||||
bool isFailure(const uint256& h) { return mRecentFailures.isPresent(h, false); }
|
||||
|
||||
|
||||
@@ -203,20 +203,28 @@ bool LedgerMaster::acquireMissingLedger(Ledger::ref origLedger, const uint256& l
|
||||
theApp->getIOService().post(boost::bind(&LedgerMaster::missingAcquireComplete, this, mMissingLedger));
|
||||
}
|
||||
|
||||
int fetch = theConfig.getSize(siLedgerFetch);
|
||||
if (theApp->getMasterLedgerAcquire().getFetchCount() < fetch)
|
||||
{
|
||||
int count = 0;
|
||||
typedef std::pair<uint32, uint256> u_pair;
|
||||
int fetchMax = theConfig.getSize(siLedgerFetch);
|
||||
int timeoutCount;
|
||||
int fetchCount = theApp->getMasterLedgerAcquire().getFetchCount(timeoutCount);
|
||||
|
||||
std::vector<u_pair> vec = origLedger->getLedgerHashes();
|
||||
BOOST_REVERSE_FOREACH(const u_pair& it, vec)
|
||||
if (fetchCount < fetchMax)
|
||||
{
|
||||
if (timeoutCount > 4)
|
||||
{
|
||||
if ((count < fetch) && (it.first < ledgerSeq) &&
|
||||
!mCompleteLedgers.hasValue(it.first) && !theApp->getMasterLedgerAcquire().find(it.second))
|
||||
cLog(lsDEBUG) << "Not acquiring due to timeouts";
|
||||
}
|
||||
else
|
||||
{
|
||||
typedef std::pair<uint32, uint256> u_pair;
|
||||
std::vector<u_pair> vec = origLedger->getLedgerHashes();
|
||||
BOOST_REVERSE_FOREACH(const u_pair& it, vec)
|
||||
{
|
||||
++count;
|
||||
theApp->getMasterLedgerAcquire().findCreate(it.second);
|
||||
if ((fetchCount < fetchMax) && (it.first < ledgerSeq) &&
|
||||
!mCompleteLedgers.hasValue(it.first) && !theApp->getMasterLedgerAcquire().find(it.second))
|
||||
{
|
||||
++fetchCount;
|
||||
theApp->getMasterLedgerAcquire().findCreate(it.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user