Don't allow an unlimited amount of work to build up for the ledger accept engine.

This commit is contained in:
JoelKatz
2012-10-28 19:36:02 -07:00
parent c9a2482c95
commit 851d21a5aa
4 changed files with 45 additions and 5 deletions

View File

@@ -430,12 +430,16 @@ void Ledger::saveAcceptedLedger(bool fromConsensus)
}
if (!fromConsensus)
{
decPendingSaves();
return;
}
theApp->getMasterLedger().setFullLedger(shared_from_this());
theApp->getOPs().pubLedger(shared_from_this());
decPendingSaves();
}
Ledger::pointer Ledger::getSQL(const std::string& sql)
@@ -1022,4 +1026,28 @@ bool Ledger::assertSane()
return false;
}
int Ledger::sPendingSaves = 0;
boost::recursive_mutex Ledger::sPendingSaveLock;
int Ledger::getPendingSaves()
{
boost::recursive_mutex::scoped_lock sl(sPendingSaveLock);
return sPendingSaves;
}
void Ledger::pendSave(bool fromConsensus)
{
boost::thread thread(boost::bind(&Ledger::saveAcceptedLedger, shared_from_this(), fromConsensus));
thread.detach();
boost::recursive_mutex::scoped_lock sl(sPendingSaveLock);
++sPendingSaves;
}
void Ledger::decPendingSaves()
{
boost::recursive_mutex::scoped_lock sl(sPendingSaveLock);
--sPendingSaves;
}
// vim:ts=4