Clean up old acquires.

This commit is contained in:
JoelKatz
2013-01-07 08:57:20 -08:00
parent e9fad1a431
commit 6624e31d5a
3 changed files with 17 additions and 0 deletions

View File

@@ -275,6 +275,7 @@ void Application::sweep()
mLedgerMaster.sweep();
mTempNodeCache.sweep();
mValidations.sweep();
getMasterLedgerAcquire().sweep();
mSweepTimer.expires_from_now(boost::posix_time::seconds(60));
mSweepTimer.async_wait(boost::bind(&Application::sweep, this));
}

View File

@@ -724,4 +724,18 @@ bool LedgerAcquireMaster::isFailure(const uint256& hash)
return mRecentFailures.find(hash) != mRecentFailures.end();
}
void LedgerAcquireMaster::sweep()
{
boost::mutex::scoped_lock sl(mLock);
std::map<uint256, LedgerAcquire::pointer>::iterator it = mLedgers.begin();
while (it != mLedgers.end())
{
if (it->second->isDone())
mLedgers.erase(it++);
else
++it;
}
}
// vim:ts=4

View File

@@ -133,6 +133,8 @@ public:
void logFailure(const uint256&);
bool isFailure(const uint256&);
void sweep();
};
#endif