diff --git a/src/cpp/ripple/Ledger.cpp b/src/cpp/ripple/Ledger.cpp index 35667e3157..d8dcea2663 100644 --- a/src/cpp/ripple/Ledger.cpp +++ b/src/cpp/ripple/Ledger.cpp @@ -517,12 +517,12 @@ void Ledger::saveAcceptedLedger(Job&, bool fromConsensus) if (!fromConsensus) { - decPendingSaves(); dropCache(); return; } - decPendingSaves(); + if (theApp->getJobQueue().getJobCount(jtPUBOLDLEDGER) == 0) + theApp->getLedgerMaster().resumeAcquiring(); } #ifndef NO_SQLITE3_PREPARE @@ -1501,15 +1501,6 @@ void Ledger::updateSkipList() } } -int Ledger::sPendingSaves = 0; -boost::recursive_mutex Ledger::sPendingSaveLock; - -int Ledger::getPendingSaves() -{ - boost::recursive_mutex::scoped_lock sl(sPendingSaveLock); - return sPendingSaves; -} - uint32 Ledger::roundCloseTime(uint32 closeTime, uint32 closeResolution) { if (closeTime == 0) @@ -1524,27 +1515,12 @@ void Ledger::pendSave(bool fromConsensus) return; assert(isImmutable()); - { - boost::recursive_mutex::scoped_lock sl(sPendingSaveLock); - ++sPendingSaves; - } - - theApp->getJobQueue().addJob(jtPUBOLDLEDGER, "Ledger::pendSave", // FIXME not old if fromConsensus + theApp->getJobQueue().addJob(fromconsensus ? jtPUBLEDGER : jtPUBOLDLEDGER, + fromConsensus ? "Ledger::pendSave" : "Ledger::pendOldSave", boost::bind(&Ledger::saveAcceptedLedger, shared_from_this(), _1, fromConsensus)); } -void Ledger::decPendingSaves() -{ - { - boost::recursive_mutex::scoped_lock sl(sPendingSaveLock); - --sPendingSaves; - if (sPendingSaves != 0) - return; - } - theApp->getLedgerMaster().resumeAcquiring(); -} - void Ledger::ownerDirDescriber(SLE::ref sle, const uint160& owner) { sle->setFieldAccount(sfOwner, owner); diff --git a/src/cpp/ripple/Ledger.h b/src/cpp/ripple/Ledger.h index 847bf065f3..0744834602 100644 --- a/src/cpp/ripple/Ledger.h +++ b/src/cpp/ripple/Ledger.h @@ -89,9 +89,6 @@ private: mutable boost::recursive_mutex mLock; - static int sPendingSaves; - static boost::recursive_mutex sPendingSaveLock; - Ledger(const Ledger&); // no implementation Ledger& operator=(const Ledger&); // no implementation @@ -101,8 +98,6 @@ protected: // returned SLE is immutable SLE::pointer getASNodeI(const uint256& nodeID, LedgerEntryType let); - static void incPendingSaves(); - static void decPendingSaves(); void saveAcceptedLedger(Job&, bool fromConsensus); void updateFees(); @@ -126,7 +121,6 @@ public: static Ledger::pointer getSQL1(SqliteStatement*); static void getSQL2(Ledger::ref); static Ledger::pointer getLastFullLedger(); - static int getPendingSaves(); static uint32 roundCloseTime(uint32 closeTime, uint32 closeResolution); void updateHash(); diff --git a/src/cpp/ripple/LedgerMaster.cpp b/src/cpp/ripple/LedgerMaster.cpp index c4a20dc331..6b14b8123c 100644 --- a/src/cpp/ripple/LedgerMaster.cpp +++ b/src/cpp/ripple/LedgerMaster.cpp @@ -388,7 +388,7 @@ void LedgerMaster::setFullLedger(Ledger::ref ledger) return; } - if (Ledger::getPendingSaves() > 2) + if (theApp->getJobQueue().getJobCount(jtPUBOLDLEDGER) > 2) { mTooFast = true; cLog(lsDEBUG) << "Too many pending ledger saves";