diff --git a/Builds/VisualStudio2015/RippleD.vcxproj b/Builds/VisualStudio2015/RippleD.vcxproj index a763ed78f6..e5fbd1eceb 100644 --- a/Builds/VisualStudio2015/RippleD.vcxproj +++ b/Builds/VisualStudio2015/RippleD.vcxproj @@ -1877,8 +1877,6 @@ - - diff --git a/Builds/VisualStudio2015/RippleD.vcxproj.filters b/Builds/VisualStudio2015/RippleD.vcxproj.filters index 63d0722070..dbe9081d3d 100644 --- a/Builds/VisualStudio2015/RippleD.vcxproj.filters +++ b/Builds/VisualStudio2015/RippleD.vcxproj.filters @@ -2616,9 +2616,6 @@ ripple\basics - - ripple\basics - ripple\basics diff --git a/src/ripple/app/ledger/BookListeners.cpp b/src/ripple/app/ledger/BookListeners.cpp index c610e94cdd..e84aa922c0 100644 --- a/src/ripple/app/ledger/BookListeners.cpp +++ b/src/ripple/app/ledger/BookListeners.cpp @@ -26,13 +26,13 @@ namespace ripple { void BookListeners::addSubscriber (InfoSub::ref sub) { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); mListeners[sub->getSeq ()] = sub; } void BookListeners::removeSubscriber (std::uint64_t seq) { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); mListeners.erase (seq); } @@ -40,7 +40,7 @@ void BookListeners::publish (Json::Value const& jvObj) { std::string sObj = to_string (jvObj); - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); auto it = mListeners.cbegin (); while (it != mListeners.cend ()) diff --git a/src/ripple/app/ledger/BookListeners.h b/src/ripple/app/ledger/BookListeners.h index f59d058ab5..e24adae56e 100644 --- a/src/ripple/app/ledger/BookListeners.h +++ b/src/ripple/app/ledger/BookListeners.h @@ -22,6 +22,7 @@ #include #include +#include namespace ripple { @@ -38,9 +39,7 @@ public: void publish (Json::Value const& jvObj); private: - using LockType = RippleRecursiveMutex; - using ScopedLockType = std::lock_guard ; - LockType mLock; + std::recursive_mutex mLock; hash_map mListeners; }; diff --git a/src/ripple/app/ledger/InboundLedger.h b/src/ripple/app/ledger/InboundLedger.h index 13b3b2c176..45883abbf7 100644 --- a/src/ripple/app/ledger/InboundLedger.h +++ b/src/ripple/app/ledger/InboundLedger.h @@ -24,6 +24,7 @@ #include #include #include +#include #include namespace ripple { @@ -160,7 +161,7 @@ private: std::set mRecentNodes; // Data we have received from peers - PeerSet::LockType mReceivedDataLock; + std::recursive_mutex mReceivedDataLock; std::vector mReceivedData; bool mReceiveDispatched; diff --git a/src/ripple/app/ledger/LedgerHolder.h b/src/ripple/app/ledger/LedgerHolder.h index 417fb3f98e..eeda392a44 100644 --- a/src/ripple/app/ledger/LedgerHolder.h +++ b/src/ripple/app/ledger/LedgerHolder.h @@ -20,6 +20,8 @@ #ifndef RIPPLE_APP_LEDGER_LEDGERHOLDER_H_INCLUDED #define RIPPLE_APP_LEDGER_LEDGERHOLDER_H_INCLUDED +#include + namespace ripple { // Can std::atomic> make this lock free? @@ -29,9 +31,6 @@ namespace ripple { class LedgerHolder { public: - using LockType = RippleMutex; - using ScopedLockType = std::lock_guard ; - // Update the held ledger void set (Ledger::pointer ledger) { @@ -40,8 +39,7 @@ public: ledger = std::make_shared (*ledger, false); { - ScopedLockType sl (m_lock); - + std::lock_guard sl (m_lock); m_heldLedger = ledger; } } @@ -49,8 +47,7 @@ public: // Return the (immutable) held ledger Ledger::pointer get () { - ScopedLockType sl (m_lock); - + std::lock_guard sl (m_lock); return m_heldLedger; } @@ -61,19 +58,15 @@ public: return ret ? std::make_shared (*ret, true) : ret; } - bool empty () { - ScopedLockType sl (m_lock); - + std::lock_guard sl (m_lock); return m_heldLedger == nullptr; } private: - - LockType m_lock; + std::mutex m_lock; Ledger::pointer m_heldLedger; - }; } // ripple diff --git a/src/ripple/app/ledger/LedgerMaster.h b/src/ripple/app/ledger/LedgerMaster.h index 223c813975..f3266ff2c6 100644 --- a/src/ripple/app/ledger/LedgerMaster.h +++ b/src/ripple/app/ledger/LedgerMaster.h @@ -31,6 +31,7 @@ #include #include #include +#include #include "ripple.pb.h" @@ -63,10 +64,6 @@ public: using callback = std::function ; public: - using LockType = RippleRecursiveMutex; - using ScopedLockType = std::unique_lock ; - using ScopedUnlockType = beast::GenericScopedUnlock ; - virtual ~LedgerMaster () = default; virtual LedgerIndex getCurrentLedgerIndex () = 0; @@ -75,7 +72,7 @@ public: virtual bool isCompatible (Ledger::pointer, beast::Journal::Stream, const char* reason) = 0; - virtual LockType& peekMutex () = 0; + virtual std::recursive_mutex& peekMutex () = 0; // The current ledger is the ledger we believe new transactions should go in virtual std::shared_ptr getCurrentLedger () = 0; diff --git a/src/ripple/app/ledger/OrderBookDB.cpp b/src/ripple/app/ledger/OrderBookDB.cpp index 68c8f15471..8ffff6822c 100644 --- a/src/ripple/app/ledger/OrderBookDB.cpp +++ b/src/ripple/app/ledger/OrderBookDB.cpp @@ -38,7 +38,7 @@ OrderBookDB::OrderBookDB (Application& app, Stoppable& parent) void OrderBookDB::invalidate () { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); mSeq = 0; } @@ -46,7 +46,7 @@ void OrderBookDB::setup( std::shared_ptr const& ledger) { { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); auto seq = ledger->info().seq; // Do a full update every 256 ledgers @@ -122,7 +122,7 @@ void OrderBookDB::update( { JLOG (j_.info) << "OrderBookDB::update encountered a missing node"; - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); mSeq = 0; return; } @@ -130,7 +130,7 @@ void OrderBookDB::update( JLOG (j_.debug) << "OrderBookDB::update< " << books << " books found"; { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); mXRPBooks.swap(XRPBooks); mSourceMap.swap(sourceMap); @@ -142,7 +142,7 @@ void OrderBookDB::update( void OrderBookDB::addOrderBook(Book const& book) { bool toXRP = isXRP (book.out); - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); if (toXRP) { @@ -177,26 +177,26 @@ void OrderBookDB::addOrderBook(Book const& book) // return list of all orderbooks that want this issuerID and currencyID OrderBook::List OrderBookDB::getBooksByTakerPays (Issue const& issue) { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); auto it = mSourceMap.find (issue); return it == mSourceMap.end () ? OrderBook::List() : it->second; } int OrderBookDB::getBookSize(Issue const& issue) { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); auto it = mSourceMap.find (issue); return it == mSourceMap.end () ? 0 : it->second.size(); } bool OrderBookDB::isBookToXRP(Issue const& issue) { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); return mXRPBooks.count(issue) > 0; } BookListeners::pointer OrderBookDB::makeBookListeners (Book const& book) { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); auto ret = getBookListeners (book); if (!ret) @@ -213,7 +213,7 @@ BookListeners::pointer OrderBookDB::makeBookListeners (Book const& book) BookListeners::pointer OrderBookDB::getBookListeners (Book const& book) { BookListeners::pointer ret; - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); auto it0 = mListeners.find (book); if (it0 != mListeners.end ()) @@ -228,7 +228,7 @@ void OrderBookDB::processTxn ( std::shared_ptr const& ledger, const AcceptedLedgerTx& alTx, Json::Value const& jvObj) { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); if (alTx.getResult () == tesSUCCESS) { diff --git a/src/ripple/app/ledger/OrderBookDB.h b/src/ripple/app/ledger/OrderBookDB.h index dee03f1d5d..d565faf4a5 100644 --- a/src/ripple/app/ledger/OrderBookDB.h +++ b/src/ripple/app/ledger/OrderBookDB.h @@ -24,6 +24,7 @@ #include #include #include +#include namespace ripple { @@ -73,9 +74,7 @@ private: // does an order book to XRP exist hash_set mXRPBooks; - using LockType = RippleRecursiveMutex; - using ScopedLockType = std::lock_guard ; - LockType mLock; + std::recursive_mutex mLock; using BookToListenersMap = hash_map ; diff --git a/src/ripple/app/ledger/impl/InboundLedgers.cpp b/src/ripple/app/ledger/impl/InboundLedgers.cpp index 0c352abbad..89d795b09f 100644 --- a/src/ripple/app/ledger/impl/InboundLedgers.cpp +++ b/src/ripple/app/ledger/impl/InboundLedgers.cpp @@ -29,6 +29,7 @@ #include // #include #include +#include namespace ripple { @@ -415,13 +416,12 @@ public: private: clock_type& m_clock; + using ScopedLockType = std::unique_lock ; + std::recursive_mutex mLock; + using MapType = hash_map ; - - using LockType = RippleRecursiveMutex; - using ScopedLockType = std::unique_lock ; - LockType mLock; - MapType mLedgers; + beast::aged_map mRecentFailures; beast::insight::Counter mCounter; diff --git a/src/ripple/app/ledger/impl/LedgerConsensusImp.cpp b/src/ripple/app/ledger/impl/LedgerConsensusImp.cpp index 40c1dd3b08..bbcbccd194 100644 --- a/src/ripple/app/ledger/impl/LedgerConsensusImp.cpp +++ b/src/ripple/app/ledger/impl/LedgerConsensusImp.cpp @@ -1178,10 +1178,9 @@ void LedgerConsensusImp::accept (std::shared_ptr set) { // Build new open ledger - auto lock = beast::make_lock( app_.getMasterMutex(), std::defer_lock); - LedgerMaster::ScopedLockType sl ( + auto sl = beast::make_lock( ledgerMaster_.peekMutex (), std::defer_lock); std::lock(lock, sl); diff --git a/src/ripple/app/ledger/impl/LedgerMaster.cpp b/src/ripple/app/ledger/impl/LedgerMaster.cpp index 3605881a16..1301ad399d 100644 --- a/src/ripple/app/ledger/impl/LedgerMaster.cpp +++ b/src/ripple/app/ledger/impl/LedgerMaster.cpp @@ -65,14 +65,13 @@ class LedgerMasterImp : public LedgerMaster { public: - using LockType = RippleRecursiveMutex; - using ScopedLockType = std::lock_guard ; - using ScopedUnlockType = beast::GenericScopedUnlock ; + using ScopedLockType = std::lock_guard ; + using ScopedUnlockType = beast::GenericScopedUnlock ; Application& app_; beast::Journal m_journal; - LockType m_mutex; + std::recursive_mutex m_mutex; // The ledger that most recently closed. LedgerHolder mClosedLedger; @@ -99,7 +98,7 @@ public: // A set of transactions to replay during the next close std::unique_ptr replayData; - LockType mCompleteLock; + std::recursive_mutex mCompleteLock; RangeSet mCompleteLedgers; std::unique_ptr mLedgerCleaner; @@ -1289,7 +1288,7 @@ public: } } - LockType& peekMutex () override + std::recursive_mutex& peekMutex () override { return m_mutex; } diff --git a/src/ripple/app/misc/AmendmentTableImpl.cpp b/src/ripple/app/misc/AmendmentTableImpl.cpp index 9c40bc16eb..ae2ee4c72c 100644 --- a/src/ripple/app/misc/AmendmentTableImpl.cpp +++ b/src/ripple/app/misc/AmendmentTableImpl.cpp @@ -28,6 +28,7 @@ #include #include #include +#include namespace ripple { /** Track the list of "amendments" @@ -43,9 +44,7 @@ protected: using amendmentMap_t = hash_map; using amendmentList_t = hash_set; - using LockType = RippleMutex; - using ScopedLockType = std::lock_guard ; - LockType mLock; + std::mutex mLock; amendmentMap_t m_amendmentMap; std::uint32_t m_lastUpdateSeq; @@ -213,7 +212,7 @@ AmendmentTableImpl::getExisting (uint256 const& amendmentHash) uint256 AmendmentTableImpl::get (std::string const& name) { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); for (auto const& e : m_amendmentMap) { @@ -237,7 +236,7 @@ AmendmentTableImpl::addKnown (AmendmentName const& name) throw std::runtime_error (errorMsg); } - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); AmendmentState& amendment = getCreate (name.id ()); if (!name.friendlyName ().empty ()) @@ -250,7 +249,7 @@ AmendmentTableImpl::addKnown (AmendmentName const& name) bool AmendmentTableImpl::veto (uint256 const& amendment) { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); AmendmentState& s = getCreate (amendment); if (s.mVetoed) @@ -263,7 +262,7 @@ AmendmentTableImpl::veto (uint256 const& amendment) bool AmendmentTableImpl::unVeto (uint256 const& amendment) { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); AmendmentState* s = getExisting (amendment); if (!s || !s->mVetoed) @@ -276,7 +275,7 @@ AmendmentTableImpl::unVeto (uint256 const& amendment) bool AmendmentTableImpl::enable (uint256 const& amendment) { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); AmendmentState& s = getCreate (amendment); if (s.mEnabled) @@ -289,7 +288,7 @@ AmendmentTableImpl::enable (uint256 const& amendment) bool AmendmentTableImpl::disable (uint256 const& amendment) { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); AmendmentState* s = getExisting (amendment); if (!s || !s->mEnabled) @@ -302,7 +301,7 @@ AmendmentTableImpl::disable (uint256 const& amendment) bool AmendmentTableImpl::isEnabled (uint256 const& amendment) { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); AmendmentState* s = getExisting (amendment); return s && s->mEnabled; } @@ -310,7 +309,7 @@ AmendmentTableImpl::isEnabled (uint256 const& amendment) bool AmendmentTableImpl::isSupported (uint256 const& amendment) { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); AmendmentState* s = getExisting (amendment); return s && s->mSupported; } @@ -319,7 +318,7 @@ AmendmentTableImpl::amendmentList_t AmendmentTableImpl::getVetoed () { amendmentList_t ret; - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); for (auto const& e : m_amendmentMap) { if (e.second.mVetoed) @@ -332,7 +331,7 @@ AmendmentTableImpl::amendmentList_t AmendmentTableImpl::getEnabled () { amendmentList_t ret; - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); for (auto const& e : m_amendmentMap) { if (e.second.mEnabled) @@ -345,7 +344,7 @@ AmendmentTableImpl::amendmentList_t AmendmentTableImpl::getDesired (enabledAmendments_t const& enabled) { amendmentList_t ret; - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); for (auto const& e : m_amendmentMap) { @@ -360,7 +359,7 @@ AmendmentTableImpl::getDesired (enabledAmendments_t const& enabled) void AmendmentTableImpl::setEnabled (const std::vector& amendments) { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); for (auto& e : m_amendmentMap) { e.second.mEnabled = false; @@ -374,7 +373,7 @@ AmendmentTableImpl::setEnabled (const std::vector& amendments) void AmendmentTableImpl::setSupported (const std::vector& amendments) { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); for (auto &e : m_amendmentMap) { e.second.mSupported = false; @@ -443,7 +442,7 @@ AmendmentTableImpl::doVoting ( std::map actions; { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); // process all amendments we know of for (auto const& entry : m_amendmentMap) @@ -486,7 +485,7 @@ AmendmentTableImpl::doVoting ( bool AmendmentTableImpl::needValidatedLedger (LedgerIndex ledgerSeq) { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); // Is there a ledger in which an amendment could have been enabled // between these two ledger sequences? @@ -498,7 +497,7 @@ void AmendmentTableImpl::doValidatedLedger (LedgerIndex ledgerSeq, enabledAmendments_t enabled) { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); for (auto& e : m_amendmentMap) e.second.mEnabled = (enabled.count (e.first) != 0); @@ -509,7 +508,7 @@ AmendmentTableImpl::getJson (int) { Json::Value ret(Json::objectValue); { - ScopedLockType sl(mLock); + std::lock_guard sl(mLock); for (auto const& e : m_amendmentMap) { setJson (ret[to_string (e.first)] = Json::objectValue, e.second); @@ -536,7 +535,7 @@ AmendmentTableImpl::getJson (uint256 const& amendmentID) Json::Value& jAmendment = (ret[to_string (amendmentID)] = Json::objectValue); { - ScopedLockType sl(mLock); + std::lock_guard sl(mLock); AmendmentState& amendmentState = getCreate (amendmentID); setJson (jAmendment, amendmentState); diff --git a/src/ripple/app/misc/NetworkOPs.cpp b/src/ripple/app/misc/NetworkOPs.cpp index 93e132c9fa..b6ba77d7b9 100644 --- a/src/ripple/app/misc/NetworkOPs.cpp +++ b/src/ripple/app/misc/NetworkOPs.cpp @@ -70,6 +70,7 @@ #include #include #include +#include namespace ripple { @@ -426,8 +427,7 @@ private: using subRpcMapType = hash_map; // XXX Split into more locks. - using LockType = RippleRecursiveMutex; - using ScopedLockType = std::lock_guard ; + using ScopedLockType = std::lock_guard ; Application& app_; clock_type& m_clock; @@ -435,7 +435,7 @@ private: std::unique_ptr m_localTX; - LockType mSubLock; + std::recursive_mutex mSubLock; std::atomic mMode; diff --git a/src/ripple/app/misc/UniqueNodeList.cpp b/src/ripple/app/misc/UniqueNodeList.cpp index 2c1c9860b0..7bd1f6aa73 100644 --- a/src/ripple/app/misc/UniqueNodeList.cpp +++ b/src/ripple/app/misc/UniqueNodeList.cpp @@ -43,6 +43,7 @@ #include #include #include +#include namespace ripple { @@ -205,13 +206,8 @@ private: private: Application& app_; - typedef RippleMutex FetchLockType; - typedef std::lock_guard ScopedFetchLockType; - FetchLockType mFetchLock; - - typedef RippleRecursiveMutex UNLLockType; - typedef std::lock_guard ScopedUNLLockType; - UNLLockType mUNLLock; + std::mutex mFetchLock; + std::recursive_mutex mUNLLock; // VFALCO TODO Replace ptime with beast::Time // Misc persistent information @@ -485,14 +481,14 @@ void UniqueNodeListImp::start() void UniqueNodeListImp::insertEphemeralKey (PublicKey pk, std::string comment) { - ScopedUNLLockType sl (mUNLLock); + std::lock_guard sl (mUNLLock); ephemeralValidatorKeys_.insert (std::make_pair(std::move(pk), std::move(comment))); } void UniqueNodeListImp::deleteEphemeralKey (PublicKey const& pk) { - ScopedUNLLockType sl (mUNLLock); + std::lock_guard sl (mUNLLock); ephemeralValidatorKeys_.erase (pk); } @@ -596,7 +592,7 @@ void UniqueNodeListImp::nodeRemovePublic (RippleAddress const& naNodePublic) // YYY Only dirty on successful delete. fetchDirty (); - ScopedUNLLockType sl (mUNLLock); + std::lock_guard sl (mUNLLock); mUNL.erase (naNodePublic.humanNodePublic ()); } @@ -646,7 +642,7 @@ bool UniqueNodeListImp::nodeInUNL (RippleAddress const& naNodePublic) auto const& blob = naNodePublic.getNodePublic(); PublicKey const pk (Slice(blob.data(), blob.size())); - ScopedUNLLockType sl (mUNLLock); + std::lock_guard sl (mUNLLock); if (ephemeralValidatorKeys_.find (pk) != ephemeralValidatorKeys_.end()) { @@ -660,7 +656,7 @@ bool UniqueNodeListImp::nodeInUNL (RippleAddress const& naNodePublic) bool UniqueNodeListImp::nodeInCluster (RippleAddress const& naNodePublic) { - ScopedUNLLockType sl (mUNLLock); + std::lock_guard sl (mUNLLock); return m_clusterNodes.end () != m_clusterNodes.find (naNodePublic); } @@ -668,7 +664,7 @@ bool UniqueNodeListImp::nodeInCluster (RippleAddress const& naNodePublic) bool UniqueNodeListImp::nodeInCluster (RippleAddress const& naNodePublic, std::string& name) { - ScopedUNLLockType sl (mUNLLock); + std::lock_guard sl (mUNLLock); std::map::iterator it = m_clusterNodes.find (naNodePublic); if (it == m_clusterNodes.end ()) @@ -682,7 +678,7 @@ bool UniqueNodeListImp::nodeInCluster (RippleAddress const& naNodePublic, std::s bool UniqueNodeListImp::nodeUpdate (RippleAddress const& naNodePublic, ClusterNodeStatus const& cnsStatus) { - ScopedUNLLockType sl (mUNLLock); + std::lock_guard sl (mUNLLock); return m_clusterNodes[naNodePublic].update(cnsStatus); } @@ -693,7 +689,7 @@ UniqueNodeListImp::getClusterStatus() { std::map ret; { - ScopedUNLLockType sl (mUNLLock); + std::lock_guard sl (mUNLLock); ret = m_clusterNodes; } return ret; @@ -707,7 +703,7 @@ std::uint32_t UniqueNodeListImp::getClusterFee() std::vector fees; { - ScopedUNLLockType sl (mUNLLock); + std::lock_guard sl (mUNLLock); { for (std::map::iterator it = m_clusterNodes.begin(), end = m_clusterNodes.end(); it != end; ++it) @@ -728,7 +724,7 @@ std::uint32_t UniqueNodeListImp::getClusterFee() void UniqueNodeListImp::addClusterStatus (Json::Value& obj) { - ScopedUNLLockType sl (mUNLLock); + std::lock_guard sl (mUNLLock); if (m_clusterNodes.size() > 1) // nodes other than us { auto const now = app_.timeKeeper().now().time_since_epoch().count(); @@ -925,7 +921,7 @@ Json::Value UniqueNodeListImp::getUnlJson() ret.append (node); } - ScopedUNLLockType sl (mUNLLock); + std::lock_guard sl (mUNLLock); for (auto const& key : ephemeralValidatorKeys_) { @@ -1038,7 +1034,7 @@ void UniqueNodeListImp::trustedLoad() } auto db = app_.getWalletDB ().checkoutDb (); - ScopedUNLLockType slUNL (mUNLLock); + std::lock_guard slUNL (mUNLLock); mUNL.clear (); @@ -1414,7 +1410,7 @@ void UniqueNodeListImp::scoreCompute() } { - ScopedUNLLockType sl (mUNLLock); + std::lock_guard sl (mUNLLock); // XXX Should limit to scores above a certain minimum and limit to a certain number. mUNL.swap (usUNL); @@ -1647,7 +1643,7 @@ void UniqueNodeListImp::fetchNext() bool bFull; { - ScopedFetchLockType sl (mFetchLock); + std::lock_guard sl (mFetchLock); bFull = (mFetchActive == NODE_FETCH_JOBS); } @@ -1685,7 +1681,7 @@ void UniqueNodeListImp::fetchNext() if (!strDomain.empty ()) { - ScopedFetchLockType sl (mFetchLock); + std::lock_guard sl (mFetchLock); bFull = (mFetchActive == NODE_FETCH_JOBS); @@ -1761,7 +1757,7 @@ void UniqueNodeListImp::fetchDirty() void UniqueNodeListImp::fetchFinish() { { - ScopedFetchLockType sl (mFetchLock); + std::lock_guard sl (mFetchLock); mFetchActive--; } diff --git a/src/ripple/app/paths/PathRequest.h b/src/ripple/app/paths/PathRequest.h index 32ae204c8f..79d5f8670d 100644 --- a/src/ripple/app/paths/PathRequest.h +++ b/src/ripple/app/paths/PathRequest.h @@ -28,6 +28,7 @@ #include #include #include +#include #include namespace ripple { @@ -91,6 +92,8 @@ public: bool hasCompletion (); private: + using ScopedLockType = std::lock_guard ; + bool isValid (RippleLineCache::ref crCache); void setValid (); void resetLevel (int level); @@ -105,9 +108,7 @@ private: Application& app_; beast::Journal m_journal; - using LockType = RippleRecursiveMutex; - using ScopedLockType = std::lock_guard ; - LockType mLock; + std::recursive_mutex mLock; PathRequests& mOwner; @@ -128,7 +129,7 @@ private: bool convert_all_; - LockType mIndexLock; + std::recursive_mutex mIndexLock; LedgerIndex mLastIndex; bool mInProgress; diff --git a/src/ripple/app/paths/PathRequests.h b/src/ripple/app/paths/PathRequests.h index db750a004d..07f74f5642 100644 --- a/src/ripple/app/paths/PathRequests.h +++ b/src/ripple/app/paths/PathRequests.h @@ -25,13 +25,14 @@ #include #include #include +#include namespace ripple { class PathRequests { public: - PathRequests (Application& app, + PathRequests (Application& app, beast::Journal journal, beast::insight::Collector::ptr const& collector) : app_ (app) , mJournal (journal) @@ -85,9 +86,8 @@ private: std::atomic mLastIdentifier; - using LockType = RippleRecursiveMutex; - using ScopedLockType = std::lock_guard ; - LockType mLock; + using ScopedLockType = std::lock_guard ; + std::recursive_mutex mLock; }; diff --git a/src/ripple/app/paths/RippleLineCache.cpp b/src/ripple/app/paths/RippleLineCache.cpp index 11c773d0bd..6ddacbcb39 100644 --- a/src/ripple/app/paths/RippleLineCache.cpp +++ b/src/ripple/app/paths/RippleLineCache.cpp @@ -37,7 +37,7 @@ RippleLineCache::getRippleLines (AccountID const& accountID) { AccountKey key (accountID, hasher_ (accountID)); - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); auto it = mRLMap.emplace (key, RippleStateVector ()); diff --git a/src/ripple/app/paths/RippleLineCache.h b/src/ripple/app/paths/RippleLineCache.h index 93d08231cf..0c2beece89 100644 --- a/src/ripple/app/paths/RippleLineCache.h +++ b/src/ripple/app/paths/RippleLineCache.h @@ -25,6 +25,7 @@ #include #include #include +#include #include namespace ripple { @@ -49,9 +50,7 @@ public: getRippleLines (AccountID const& accountID); private: - using LockType = RippleMutex; - using ScopedLockType = std::lock_guard ; - LockType mLock; + std::mutex mLock; ripple::hardened_hash<> hasher_; std::shared_ptr mLedger; diff --git a/src/ripple/app/tx/impl/InboundTransactions.cpp b/src/ripple/app/tx/impl/InboundTransactions.cpp index c494083acb..831621775f 100644 --- a/src/ripple/app/tx/impl/InboundTransactions.cpp +++ b/src/ripple/app/tx/impl/InboundTransactions.cpp @@ -28,6 +28,7 @@ #include #include #include // +#include namespace ripple { @@ -277,9 +278,8 @@ private: using MapType = hash_map ; - using LockType = RippleRecursiveMutex; - using ScopedLockType = std::unique_lock ; - LockType mLock; + using ScopedLockType = std::lock_guard ; + std::recursive_mutex mLock; MapType m_map; std::uint32_t m_seq; diff --git a/src/ripple/basics/BasicTypes.h b/src/ripple/basics/BasicTypes.h deleted file mode 100644 index 2ea8fa896c..0000000000 --- a/src/ripple/basics/BasicTypes.h +++ /dev/null @@ -1,33 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012, 2013 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef RIPPLE_BASICS_BASICTYPES_H_INCLUDED -#define RIPPLE_BASICS_BASICTYPES_H_INCLUDED - -#include - -namespace ripple { - -// VFALCO DEPRECATED -using RippleMutex = std::mutex; -using RippleRecursiveMutex = std::recursive_mutex; - -} // ripple - -#endif diff --git a/src/ripple/core/Job.h b/src/ripple/core/Job.h index 4eea3305d7..294a64c988 100644 --- a/src/ripple/core/Job.h +++ b/src/ripple/core/Job.h @@ -20,7 +20,6 @@ #ifndef RIPPLE_CORE_JOB_H_INCLUDED #define RIPPLE_CORE_JOB_H_INCLUDED -#include #include namespace ripple { diff --git a/src/ripple/overlay/PeerSet.h b/src/ripple/overlay/PeerSet.h index 67700f7736..0a8dba3738 100644 --- a/src/ripple/overlay/PeerSet.h +++ b/src/ripple/overlay/PeerSet.h @@ -27,6 +27,7 @@ #include #include #include +#include namespace ripple { @@ -117,9 +118,7 @@ private: static void timerJobEntry (std::shared_ptr); protected: - // VFALCO TODO try to make some of these private - using LockType = RippleRecursiveMutex; - using ScopedLockType = std::unique_lock ; + using ScopedLockType = std::unique_lock ; PeerSet (Application& app, uint256 const& hash, int interval, bool txnData, clock_type& clock, beast::Journal journal); @@ -161,7 +160,7 @@ protected: beast::Journal m_journal; clock_type& m_clock; - LockType mLock; + std::recursive_mutex mLock; uint256 mHash; int mTimerInterval; diff --git a/src/ripple/protocol/SField.h b/src/ripple/protocol/SField.h index 412d6ebb2f..be25a4dd68 100644 --- a/src/ripple/protocol/SField.h +++ b/src/ripple/protocol/SField.h @@ -20,7 +20,6 @@ #ifndef RIPPLE_PROTOCOL_SFIELD_H_INCLUDED #define RIPPLE_PROTOCOL_SFIELD_H_INCLUDED -#include #include #include #include diff --git a/src/ripple/protocol/impl/SField.cpp b/src/ripple/protocol/impl/SField.cpp index 3186b7f632..14deba7731 100644 --- a/src/ripple/protocol/impl/SField.cpp +++ b/src/ripple/protocol/impl/SField.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include