diff --git a/src/cpp/ripple/ripple_InboundLedger.cpp b/src/cpp/ripple/ripple_InboundLedger.cpp index bd738a295e..0eaf36af90 100644 --- a/src/cpp/ripple/ripple_InboundLedger.cpp +++ b/src/cpp/ripple/ripple_InboundLedger.cpp @@ -168,15 +168,19 @@ void InboundLedger::onTimer (bool progress) void InboundLedger::awaitData () { - boost::recursive_mutex::scoped_lock sl (mLock); ++mWaitCount; } void InboundLedger::noAwaitData () -{ - boost::recursive_mutex::scoped_lock sl (mLock); - - if (mWaitCount > 0 ) --mWaitCount; +{ // subtract one if mWaitCount is greater than zero + do + { + int j = mWaitCount.get(); + if (j <= 0) + return; + if (mWaitCount.compareAndSetBool(j - 1, j)) + return; + } while (1); } void InboundLedger::addPeers () @@ -285,7 +289,7 @@ void InboundLedger::trigger (Peer::ref peer) return; } - if ((mWaitCount > 0) && peer) + if ((mWaitCount.get() > 0) && peer) { WriteLog (lsTRACE, InboundLedger) << "Skipping peer"; return; diff --git a/src/cpp/ripple/ripple_InboundLedger.h b/src/cpp/ripple/ripple_InboundLedger.h index b5327ffa4f..3988b51be8 100644 --- a/src/cpp/ripple/ripple_InboundLedger.h +++ b/src/cpp/ripple/ripple_InboundLedger.h @@ -102,16 +102,16 @@ private: boost::weak_ptr pmDowncast (); private: - Ledger::pointer mLedger; - bool mHaveBase; - bool mHaveState; - bool mHaveTransactions; - bool mAborted; - bool mSignaled; - bool mAccept; - bool mByHash; - int mWaitCount; - uint32 mSeq; + Ledger::pointer mLedger; + bool mHaveBase; + bool mHaveState; + bool mHaveTransactions; + bool mAborted; + bool mSignaled; + bool mAccept; + bool mByHash; + beast::Atomic mWaitCount; + uint32 mSeq; std::set mRecentTXNodes; std::set mRecentASNodes;