mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Don't allow an unlimited amount of work to build up for the ledger accept engine.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user