diff --git a/src/beast/extras/beast/test/pipe_stream.hpp b/src/beast/extras/beast/test/pipe_stream.hpp index b40690242..dfaef479b 100644 --- a/src/beast/extras/beast/test/pipe_stream.hpp +++ b/src/beast/extras/beast/test/pipe_stream.hpp @@ -320,7 +320,7 @@ void pipe::stream:: close() { - std::lock_guard lock{out_.m}; + std::lock_guard lock{out_.m}; out_.eof = true; if(out_.op) out_.op.get()->operator()(); diff --git a/src/beast/extras/beast/test/yield_to.hpp b/src/beast/extras/beast/test/yield_to.hpp index df5b8a341..03de3e4cb 100644 --- a/src/beast/extras/beast/test/yield_to.hpp +++ b/src/beast/extras/beast/test/yield_to.hpp @@ -120,7 +120,7 @@ spawn(F0&& f, FN&&... fn) [&](yield_context yield) { f(yield); - std::lock_guard lock{m_}; + std::lock_guard lock{m_}; if(--running_ == 0) cv_.notify_all(); } diff --git a/src/beast/extras/beast/unit_test/runner.hpp b/src/beast/extras/beast/unit_test/runner.hpp index a150edf65..366ee3e37 100644 --- a/src/beast/extras/beast/unit_test/runner.hpp +++ b/src/beast/extras/beast/unit_test/runner.hpp @@ -237,7 +237,7 @@ template void runner::testcase(std::string const& name) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); // Name may not be empty BOOST_ASSERT(default_ || ! name.empty()); // Forgot to call pass or fail @@ -253,7 +253,7 @@ template void runner::pass() { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if(default_) testcase(""); on_pass(); @@ -264,7 +264,7 @@ template void runner::fail(std::string const& reason) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if(default_) testcase(""); on_fail(reason); @@ -276,7 +276,7 @@ template void runner::log(std::string const& s) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if(default_) testcase(""); on_log(s); diff --git a/src/ripple/app/consensus/RCLConsensus.cpp b/src/ripple/app/consensus/RCLConsensus.cpp index 78de02866..1f36d811e 100644 --- a/src/ripple/app/consensus/RCLConsensus.cpp +++ b/src/ripple/app/consensus/RCLConsensus.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -40,7 +39,9 @@ #include #include #include + #include +#include namespace ripple { @@ -583,8 +584,8 @@ RCLConsensus::Adaptor::doAccept( } // Build new open ledger - auto lock = make_lock(app_.getMasterMutex(), std::defer_lock); - auto sl = make_lock(ledgerMaster_.peekMutex(), std::defer_lock); + std::unique_lock lock{app_.getMasterMutex(), std::defer_lock}; + std::unique_lock sl{ledgerMaster_.peekMutex(), std::defer_lock}; std::lock(lock, sl); auto const lastVal = ledgerMaster_.getValidatedLedger(); @@ -811,7 +812,7 @@ RCLConsensus::getJson(bool full) const { Json::Value ret; { - ScopedLockType _{mutex_}; + std::lock_guard _{mutex_}; ret = consensus_.getJson(full); } ret["validating"] = adaptor_.validating(); @@ -823,7 +824,7 @@ RCLConsensus::timerEntry(NetClock::time_point const& now) { try { - ScopedLockType _{mutex_}; + std::lock_guard _{mutex_}; consensus_.timerEntry(now); } catch (SHAMapMissingNode const& mn) @@ -839,7 +840,7 @@ RCLConsensus::gotTxSet(NetClock::time_point const& now, RCLTxSet const& txSet) { try { - ScopedLockType _{mutex_}; + std::lock_guard _{mutex_}; consensus_.gotTxSet(now, txSet); } catch (SHAMapMissingNode const& mn) @@ -858,7 +859,7 @@ RCLConsensus::simulate( NetClock::time_point const& now, boost::optional consensusDelay) { - ScopedLockType _{mutex_}; + std::lock_guard _{mutex_}; consensus_.simulate(now, consensusDelay); } @@ -867,7 +868,7 @@ RCLConsensus::peerProposal( NetClock::time_point const& now, RCLCxPeerPos const& newProposal) { - ScopedLockType _{mutex_}; + std::lock_guard _{mutex_}; return consensus_.peerProposal(now, newProposal); } @@ -956,7 +957,7 @@ RCLConsensus::startRound( RCLCxLedger const& prevLgr, hash_set const& nowUntrusted) { - ScopedLockType _{mutex_}; + std::lock_guard _{mutex_}; consensus_.startRound( now, prevLgrId, prevLgr, nowUntrusted, adaptor_.preStartRound(prevLgr)); } diff --git a/src/ripple/app/consensus/RCLConsensus.h b/src/ripple/app/consensus/RCLConsensus.h index 48894f02b..5ce6eacf4 100644 --- a/src/ripple/app/consensus/RCLConsensus.h +++ b/src/ripple/app/consensus/RCLConsensus.h @@ -470,7 +470,7 @@ public: RCLCxLedger::ID prevLedgerID() const { - ScopedLockType _{mutex_}; + std::lock_guard _{mutex_}; return consensus_.prevLedgerID(); } @@ -497,7 +497,6 @@ private: // guards all calls to consensus_. adaptor_ uses atomics internally // to allow concurrent access of its data members that have getters. mutable std::recursive_mutex mutex_; - using ScopedLockType = std::lock_guard ; Adaptor adaptor_; Consensus consensus_; diff --git a/src/ripple/app/consensus/RCLValidations.h b/src/ripple/app/consensus/RCLValidations.h index abb649937..bf5a099fd 100644 --- a/src/ripple/app/consensus/RCLValidations.h +++ b/src/ripple/app/consensus/RCLValidations.h @@ -222,7 +222,6 @@ public: } private: - using ScopedLockType = std::lock_guard; using ScopedUnlockType = GenericScopedUnlock; Application& app_; diff --git a/src/ripple/app/ledger/BookListeners.cpp b/src/ripple/app/ledger/BookListeners.cpp index e3ad2e16a..f2e1fe465 100644 --- a/src/ripple/app/ledger/BookListeners.cpp +++ b/src/ripple/app/ledger/BookListeners.cpp @@ -26,14 +26,14 @@ namespace ripple { void BookListeners::addSubscriber(InfoSub::ref sub) { - std::lock_guard sl(mLock); + std::lock_guard sl(mLock); mListeners[sub->getSeq()] = sub; } void BookListeners::removeSubscriber(std::uint64_t seq) { - std::lock_guard sl(mLock); + std::lock_guard sl(mLock); mListeners.erase(seq); } @@ -42,7 +42,7 @@ BookListeners::publish( Json::Value const& jvObj, hash_set& havePublished) { - std::lock_guard sl(mLock); + std::lock_guard sl(mLock); auto it = mListeners.cbegin(); while (it != mListeners.cend()) diff --git a/src/ripple/app/ledger/LedgerHistory.cpp b/src/ripple/app/ledger/LedgerHistory.cpp index fd097b59d..95c35166b 100644 --- a/src/ripple/app/ledger/LedgerHistory.cpp +++ b/src/ripple/app/ledger/LedgerHistory.cpp @@ -60,7 +60,7 @@ LedgerHistory::insert( assert (ledger->stateMap().getHash ().isNonZero ()); - LedgersByHash::ScopedLockType sl (m_ledgers_by_hash.peekMutex ()); + std::unique_lock sl (m_ledgers_by_hash.peekMutex ()); const bool alreadyHad = m_ledgers_by_hash.canonicalize ( ledger->info().hash, ledger, true); @@ -72,7 +72,7 @@ LedgerHistory::insert( LedgerHash LedgerHistory::getLedgerHash (LedgerIndex index) { - LedgersByHash::ScopedLockType sl (m_ledgers_by_hash.peekMutex ()); + std::unique_lock sl (m_ledgers_by_hash.peekMutex ()); auto it = mLedgersByIndex.find (index); if (it != mLedgersByIndex.end ()) @@ -85,7 +85,7 @@ std::shared_ptr LedgerHistory::getLedgerBySeq (LedgerIndex index) { { - LedgersByHash::ScopedLockType sl (m_ledgers_by_hash.peekMutex ()); + std::unique_lock sl (m_ledgers_by_hash.peekMutex ()); auto it = mLedgersByIndex.find (index); if (it != mLedgersByIndex.end ()) @@ -105,7 +105,7 @@ LedgerHistory::getLedgerBySeq (LedgerIndex index) { // Add this ledger to the local tracking by index - LedgersByHash::ScopedLockType sl (m_ledgers_by_hash.peekMutex ()); + std::unique_lock sl (m_ledgers_by_hash.peekMutex ()); assert (ret->isImmutable ()); m_ledgers_by_hash.canonicalize (ret->info().hash, ret); @@ -428,7 +428,7 @@ void LedgerHistory::builtLedger ( LedgerHash hash = ledger->info().hash; assert (!hash.isZero()); - ConsensusValidated::ScopedLockType sl ( + std::unique_lock sl ( m_consensus_validated.peekMutex()); auto entry = std::make_shared(); @@ -468,7 +468,7 @@ void LedgerHistory::validatedLedger ( LedgerHash hash = ledger->info().hash; assert (!hash.isZero()); - ConsensusValidated::ScopedLockType sl ( + std::unique_lock sl ( m_consensus_validated.peekMutex()); auto entry = std::make_shared(); @@ -504,7 +504,7 @@ void LedgerHistory::validatedLedger ( bool LedgerHistory::fixIndex ( LedgerIndex ledgerIndex, LedgerHash const& ledgerHash) { - LedgersByHash::ScopedLockType sl (m_ledgers_by_hash.peekMutex ()); + std::unique_lock sl (m_ledgers_by_hash.peekMutex ()); auto it = mLedgersByIndex.find (ledgerIndex); if ((it != mLedgersByIndex.end ()) && (it->second != ledgerHash) ) diff --git a/src/ripple/app/ledger/LedgerHolder.h b/src/ripple/app/ledger/LedgerHolder.h index 919c02bc8..a0831ccf4 100644 --- a/src/ripple/app/ledger/LedgerHolder.h +++ b/src/ripple/app/ledger/LedgerHolder.h @@ -45,20 +45,20 @@ public: LogicError("LedgerHolder::set with nullptr"); if(! ledger->isImmutable()) LogicError("LedgerHolder::set with mutable Ledger"); - std::lock_guard sl (m_lock); + std::lock_guard sl (m_lock); m_heldLedger = std::move(ledger); } // Return the (immutable) held ledger std::shared_ptr get () { - std::lock_guard sl (m_lock); + std::lock_guard sl (m_lock); return m_heldLedger; } bool empty () { - std::lock_guard sl (m_lock); + std::lock_guard sl (m_lock); return m_heldLedger == nullptr; } diff --git a/src/ripple/app/ledger/LedgerMaster.h b/src/ripple/app/ledger/LedgerMaster.h index b090de4a0..67c5cdb13 100644 --- a/src/ripple/app/ledger/LedgerMaster.h +++ b/src/ripple/app/ledger/LedgerMaster.h @@ -256,7 +256,6 @@ public: } private: - using ScopedLockType = std::lock_guard ; using ScopedUnlockType = GenericScopedUnlock ; void setValidLedger( @@ -281,8 +280,8 @@ private: bool& progress, InboundLedger::Reason reason); // Try to publish ledgers, acquire missing ledgers. Always called with - // m_mutex locked. The passed ScopedLockType is a reminder to callers. - void doAdvance(ScopedLockType&); + // m_mutex locked. The passed lock is a reminder to callers. + void doAdvance(std::lock_guard&); bool shouldAcquire( std::uint32_t const currentLedger, std::uint32_t const ledgerHistory, @@ -295,8 +294,8 @@ private: void updatePaths(Job& job); // Returns true if work started. Always called with m_mutex locked. - // The passed ScopedLockType is a reminder to callers. - bool newPFWork(const char *name, ScopedLockType&); + // The passed lock is a reminder to callers. + bool newPFWork(const char *name, std::lock_guard&); private: Application& app_; diff --git a/src/ripple/app/ledger/OrderBookDB.cpp b/src/ripple/app/ledger/OrderBookDB.cpp index 11d8bacaa..02ebbcca5 100644 --- a/src/ripple/app/ledger/OrderBookDB.cpp +++ b/src/ripple/app/ledger/OrderBookDB.cpp @@ -37,7 +37,7 @@ OrderBookDB::OrderBookDB (Application& app, Stoppable& parent) void OrderBookDB::invalidate () { - std::lock_guard sl (mLock); + std::lock_guard sl (mLock); mSeq = 0; } @@ -45,7 +45,7 @@ void OrderBookDB::setup( std::shared_ptr const& ledger) { { - std::lock_guard sl (mLock); + std::lock_guard sl (mLock); auto seq = ledger->info().seq; // Do a full update every 256 ledgers @@ -104,7 +104,7 @@ void OrderBookDB::update( { JLOG (j_.info()) << "OrderBookDB::update exiting due to isStopping"; - std::lock_guard sl (mLock); + std::lock_guard sl (mLock); mSeq = 0; return; } @@ -136,7 +136,7 @@ void OrderBookDB::update( { JLOG (j_.info()) << "OrderBookDB::update encountered a missing node"; - std::lock_guard sl (mLock); + std::lock_guard sl (mLock); mSeq = 0; return; } @@ -144,7 +144,7 @@ void OrderBookDB::update( JLOG (j_.debug()) << "OrderBookDB::update< " << books << " books found"; { - std::lock_guard sl (mLock); + std::lock_guard sl (mLock); mXRPBooks.swap(XRPBooks); mSourceMap.swap(sourceMap); @@ -156,7 +156,7 @@ void OrderBookDB::update( void OrderBookDB::addOrderBook(Book const& book) { bool toXRP = isXRP (book.out); - std::lock_guard sl (mLock); + std::lock_guard sl (mLock); if (toXRP) { @@ -191,26 +191,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) { - std::lock_guard 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) { - std::lock_guard 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) { - std::lock_guard sl (mLock); + std::lock_guard sl (mLock); return mXRPBooks.count(issue) > 0; } BookListeners::pointer OrderBookDB::makeBookListeners (Book const& book) { - std::lock_guard sl (mLock); + std::lock_guard sl (mLock); auto ret = getBookListeners (book); if (!ret) @@ -227,7 +227,7 @@ BookListeners::pointer OrderBookDB::makeBookListeners (Book const& book) BookListeners::pointer OrderBookDB::getBookListeners (Book const& book) { BookListeners::pointer ret; - std::lock_guard sl (mLock); + std::lock_guard sl (mLock); auto it0 = mListeners.find (book); if (it0 != mListeners.end ()) @@ -242,7 +242,7 @@ void OrderBookDB::processTxn ( std::shared_ptr const& ledger, const AcceptedLedgerTx& alTx, Json::Value const& jvObj) { - std::lock_guard sl (mLock); + std::lock_guard sl (mLock); if (alTx.getResult () == tesSUCCESS) { // For this particular transaction, maintain the set of unique diff --git a/src/ripple/app/ledger/PendingSaves.h b/src/ripple/app/ledger/PendingSaves.h index f64566daf..17145f593 100644 --- a/src/ripple/app/ledger/PendingSaves.h +++ b/src/ripple/app/ledger/PendingSaves.h @@ -51,7 +51,7 @@ public: bool startWork (LedgerIndex seq) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); auto it = map_.find (seq); @@ -74,7 +74,7 @@ public: void finishWork (LedgerIndex seq) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); map_.erase (seq); await_.notify_all(); @@ -84,7 +84,7 @@ public: bool pending (LedgerIndex seq) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); return map_.find(seq) != map_.end(); } @@ -137,7 +137,7 @@ public: std::map getSnapshot () const { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); return map_; } diff --git a/src/ripple/app/ledger/impl/InboundLedger.cpp b/src/ripple/app/ledger/impl/InboundLedger.cpp index 155f11d62..bc2d7ae08 100644 --- a/src/ripple/app/ledger/impl/InboundLedger.cpp +++ b/src/ripple/app/ledger/impl/InboundLedger.cpp @@ -1120,7 +1120,7 @@ bool InboundLedger::gotData(std::weak_ptr peer, std::shared_ptr const& data) { - std::lock_guard sl (mReceivedDataLock); + std::lock_guard sl (mReceivedDataLock); if (isDone ()) return false; @@ -1267,7 +1267,7 @@ void InboundLedger::runData () { data.clear(); { - std::lock_guard sl (mReceivedDataLock); + std::lock_guard sl (mReceivedDataLock); if (mReceivedData.empty ()) { diff --git a/src/ripple/app/ledger/impl/InboundLedgers.cpp b/src/ripple/app/ledger/impl/InboundLedgers.cpp index 829a5b129..4f933f30e 100644 --- a/src/ripple/app/ledger/impl/InboundLedgers.cpp +++ b/src/ripple/app/ledger/impl/InboundLedgers.cpp @@ -297,8 +297,7 @@ public: std::size_t fetchRate() override { - std::lock_guard< - std::mutex> lock(fetchRateMutex_); + std::lock_guard lock(fetchRateMutex_); return 60 * fetchRate_.value( m_clock.now()); } @@ -307,7 +306,7 @@ public: // a reason of history or shard void onLedgerFetched() override { - std::lock_guard lock(fetchRateMutex_); + std::lock_guard lock(fetchRateMutex_); fetchRate_.add(1, m_clock.now()); } diff --git a/src/ripple/app/ledger/impl/InboundTransactions.cpp b/src/ripple/app/ledger/impl/InboundTransactions.cpp index 2b5538295..2bf430fc4 100644 --- a/src/ripple/app/ledger/impl/InboundTransactions.cpp +++ b/src/ripple/app/ledger/impl/InboundTransactions.cpp @@ -87,7 +87,7 @@ public: TransactionAcquire::pointer getAcquire (uint256 const& hash) { { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); auto it = m_map.find (hash); @@ -104,7 +104,7 @@ public: TransactionAcquire::pointer ta; { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); auto it = m_map.find (hash); @@ -185,7 +185,7 @@ public: bool isNew = true; { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); auto& inboundSet = m_map [hash]; @@ -212,7 +212,7 @@ public: Json::Value& sets = (ret["sets"] = Json::arrayValue); { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); ret["seq"] = m_seq; @@ -235,7 +235,7 @@ public: void newRound (std::uint32_t seq) override { - ScopedLockType lock (mLock); + std::lock_guard lock (mLock); // Protect zero set from expiration m_zeroSet.mSeq = seq; @@ -263,7 +263,7 @@ public: void onStop () override { - ScopedLockType lock (mLock); + std::lock_guard lock (mLock); m_map.clear (); @@ -275,7 +275,6 @@ private: using MapType = hash_map ; - using ScopedLockType = std::lock_guard ; std::recursive_mutex mLock; MapType m_map; diff --git a/src/ripple/app/ledger/impl/LedgerCleaner.cpp b/src/ripple/app/ledger/impl/LedgerCleaner.cpp index 3be49724b..b75472b13 100644 --- a/src/ripple/app/ledger/impl/LedgerCleaner.cpp +++ b/src/ripple/app/ledger/impl/LedgerCleaner.cpp @@ -111,7 +111,7 @@ public: { JLOG (j_.info()) << "Stopping"; { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); shouldExit_ = true; wakeup_.notify_one(); } @@ -126,7 +126,7 @@ public: void onWrite (beast::PropertyStream::Map& map) override { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); if (maxRange_ == 0) map["status"] = "idle"; @@ -155,7 +155,7 @@ public: app_.getLedgerMaster().getFullValidatedRange (minRange, maxRange); { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); maxRange_ = maxRange; minRange_ = minRange; @@ -407,7 +407,7 @@ private: { auto shouldExit = [this]() { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); return shouldExit_; }; @@ -429,7 +429,7 @@ private: } { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); if ((minRange_ > maxRange_) || (maxRange_ == 0) || (minRange_ == 0)) { @@ -460,7 +460,7 @@ private: if (fail) { { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); ++failures_; } // Wait for acquiring to catch up to us @@ -469,7 +469,7 @@ private: else { { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); if (ledgerIndex == minRange_) ++minRange_; if (ledgerIndex == maxRange_) diff --git a/src/ripple/app/ledger/impl/LedgerMaster.cpp b/src/ripple/app/ledger/impl/LedgerMaster.cpp index 275e88299..895dc2b53 100644 --- a/src/ripple/app/ledger/impl/LedgerMaster.cpp +++ b/src/ripple/app/ledger/impl/LedgerMaster.cpp @@ -108,7 +108,7 @@ LedgerMaster::isCompatible ( } { - ScopedLockType sl (m_mutex); + std::lock_guard sl (m_mutex); if ((mLastValidLedger.second != 0) && ! areCompatible (mLastValidLedger.first, @@ -249,7 +249,7 @@ void LedgerMaster::addHeldTransaction ( std::shared_ptr const& transaction) { - ScopedLockType ml (m_mutex); + std::lock_guard ml (m_mutex); mHeldTransactions.insert (transaction->getSTransaction ()); } @@ -330,7 +330,7 @@ LedgerMaster::switchLCL(std::shared_ptr const& lastClosed) LogicError ("The new last closed ledger is open!"); { - ScopedLockType ml (m_mutex); + std::lock_guard ml (m_mutex); mClosedLedger.set (lastClosed); } @@ -366,7 +366,7 @@ LedgerMaster::storeLedger (std::shared_ptr ledger) void LedgerMaster::applyHeldTransactions () { - ScopedLockType sl (m_mutex); + std::lock_guard sl (m_mutex); app_.openLedger().modify( [&](OpenView& view, beast::Journal j) @@ -395,7 +395,7 @@ std::vector> LedgerMaster::pruneHeldTransactions(AccountID const& account, std::uint32_t const seq) { - ScopedLockType sl(m_mutex); + std::lock_guard sl(m_mutex); return mHeldTransactions.prune(account, seq); } @@ -416,14 +416,14 @@ LedgerMaster::setBuildingLedger (LedgerIndex i) bool LedgerMaster::haveLedger (std::uint32_t seq) { - ScopedLockType sl (mCompleteLock); + std::lock_guard sl (mCompleteLock); return boost::icl::contains(mCompleteLedgers, seq); } void LedgerMaster::clearLedger (std::uint32_t seq) { - ScopedLockType sl (mCompleteLock); + std::lock_guard sl (mCompleteLock); mCompleteLedgers.erase (seq); } @@ -440,7 +440,7 @@ LedgerMaster::getFullValidatedRange (std::uint32_t& minVal, std::uint32_t& maxVa boost::optional maybeMin; { - ScopedLockType sl (mCompleteLock); + std::lock_guard sl (mCompleteLock); maybeMin = prevMissing(mCompleteLedgers, maxVal); } @@ -526,7 +526,7 @@ LedgerMaster::tryFill ( while (! job.shouldCancel() && seq > 0) { { - ScopedLockType ml (m_mutex); + std::lock_guard ml (m_mutex); minHas = seq; --seq; @@ -542,7 +542,7 @@ LedgerMaster::tryFill ( return; { - ScopedLockType ml(mCompleteLock); + std::lock_guard ml(mCompleteLock); mCompleteLedgers.insert(range(minHas, maxHas)); } maxHas = minHas; @@ -572,11 +572,11 @@ LedgerMaster::tryFill ( } { - ScopedLockType ml (mCompleteLock); + std::lock_guard ml (mCompleteLock); mCompleteLedgers.insert(range(minHas, maxHas)); } { - ScopedLockType ml (m_mutex); + std::lock_guard ml (m_mutex); mFillInProgress = 0; tryAdvance(); } @@ -731,12 +731,12 @@ LedgerMaster::setFullLedger ( pendSaveValidated (app_, ledger, isSynchronous, isCurrent); { - ScopedLockType ml (mCompleteLock); + std::lock_guard ml (mCompleteLock); mCompleteLedgers.insert (ledger->info().seq); } { - ScopedLockType ml (m_mutex); + std::lock_guard ml (m_mutex); if (ledger->info().seq > mValidLedgerSeq) setValidLedger(ledger); @@ -789,7 +789,7 @@ LedgerMaster::checkAccept (uint256 const& hash, std::uint32_t seq) if (valCount >= app_.validators ().quorum ()) { - ScopedLockType ml (m_mutex); + std::lock_guard ml (m_mutex); if (seq > mLastValidLedger.second) mLastValidLedger = std::make_pair (hash, seq); } @@ -845,7 +845,7 @@ LedgerMaster::checkAccept ( // Can we advance the last fully-validated ledger? If so, can we // publish? - ScopedLockType ml (m_mutex); + std::lock_guard ml (m_mutex); if (ledger->info().seq <= mValidLedgerSeq) return; @@ -1004,7 +1004,7 @@ LedgerMaster::consensusBuilt( void LedgerMaster::advanceThread() { - ScopedLockType sl (m_mutex); + std::lock_guard sl (m_mutex); assert (!mValidLedger.empty () && mAdvanceThread); JLOG (m_journal.trace()) << "advanceThread<"; @@ -1154,7 +1154,7 @@ LedgerMaster::findNewLedgersToPublish () void LedgerMaster::tryAdvance() { - ScopedLockType ml (m_mutex); + std::lock_guard ml (m_mutex); // Can't advance without at least one fully-valid ledger mAdvanceWork = true; @@ -1206,7 +1206,7 @@ void LedgerMaster::updatePaths (Job& job) { { - ScopedLockType ml (m_mutex); + std::lock_guard ml (m_mutex); if (app_.getOPs().isNeedNetworkLedger()) { --mPathFindThread; @@ -1219,7 +1219,7 @@ LedgerMaster::updatePaths (Job& job) { std::shared_ptr lastLedger; { - ScopedLockType ml (m_mutex); + std::lock_guard ml (m_mutex); if (!mValidLedger.empty() && (!mPathLedger || @@ -1248,7 +1248,7 @@ LedgerMaster::updatePaths (Job& job) { JLOG (m_journal.debug()) << "Published ledger too old for updating paths"; - ScopedLockType ml (m_mutex); + std::lock_guard ml (m_mutex); --mPathFindThread; return; } @@ -1286,7 +1286,7 @@ LedgerMaster::updatePaths (Job& job) bool LedgerMaster::newPathRequest () { - ScopedLockType ml (m_mutex); + std::lock_guard ml (m_mutex); mPathFindNewRequest = newPFWork("pf:newRequest", ml); return mPathFindNewRequest; } @@ -1294,7 +1294,7 @@ LedgerMaster::newPathRequest () bool LedgerMaster::isNewPathRequest () { - ScopedLockType ml (m_mutex); + std::lock_guard ml (m_mutex); bool const ret = mPathFindNewRequest; mPathFindNewRequest = false; return ret; @@ -1305,7 +1305,7 @@ LedgerMaster::isNewPathRequest () bool LedgerMaster::newOrderBookDB () { - ScopedLockType ml (m_mutex); + std::lock_guard ml (m_mutex); mPathLedger.reset(); return newPFWork("pf:newOBDB", ml); @@ -1314,7 +1314,7 @@ LedgerMaster::newOrderBookDB () /** A thread needs to be dispatched to handle pathfinding work of some kind. */ bool -LedgerMaster::newPFWork (const char *name, ScopedLockType&) +LedgerMaster::newPFWork (const char *name, std::lock_guard&) { if (mPathFindThread < 2) { @@ -1361,14 +1361,14 @@ LedgerMaster::getValidatedRules () std::shared_ptr LedgerMaster::getPublishedLedger () { - ScopedLockType lock(m_mutex); + std::lock_guard lock(m_mutex); return mPubLedger; } std::string LedgerMaster::getCompleteLedgers () { - ScopedLockType sl (mCompleteLock); + std::lock_guard sl (mCompleteLock); return to_string(mCompleteLedgers); } @@ -1533,7 +1533,7 @@ LedgerMaster::doLedgerCleaner(Json::Value const& parameters) void LedgerMaster::setLedgerRangePresent (std::uint32_t minV, std::uint32_t maxV) { - ScopedLockType sl (mCompleteLock); + std::lock_guard sl (mCompleteLock); mCompleteLedgers.insert(range(minV, maxV)); } @@ -1565,7 +1565,7 @@ LedgerMaster::getPropertySource () void LedgerMaster::clearPriorLedgers (LedgerIndex seq) { - ScopedLockType sl(mCompleteLock); + std::lock_guard sl(mCompleteLock); if (seq > 0) mCompleteLedgers.erase(range(0u, seq - 1)); } @@ -1657,7 +1657,7 @@ LedgerMaster::fetchForHistory( { ledger->setFull(); { - ScopedLockType lock(m_mutex); + std::lock_guard lock(m_mutex); mShardLedger = ledger; } if (!ledger->stateMap().family().isShardBacked()) @@ -1668,7 +1668,7 @@ LedgerMaster::fetchForHistory( setFullLedger(ledger, false, false); int fillInProgress; { - ScopedLockType lock(m_mutex); + std::lock_guard lock(m_mutex); mHistLedger = ledger; fillInProgress = mFillInProgress; } @@ -1677,7 +1677,7 @@ LedgerMaster::fetchForHistory( { { // Previous ledger is in DB - ScopedLockType lock(m_mutex); + std::lock_guard lock(m_mutex); mFillInProgress = seq; } app_.getJobQueue().addJob(jtADVANCE, "tryFill", @@ -1734,7 +1734,7 @@ LedgerMaster::fetchForHistory( } // Try to publish ledgers, acquire missing ledgers -void LedgerMaster::doAdvance (ScopedLockType& sl) +void LedgerMaster::doAdvance (std::lock_guard& sl) { do { @@ -1754,7 +1754,7 @@ void LedgerMaster::doAdvance (ScopedLockType& sl) InboundLedger::Reason reason = InboundLedger::Reason::HISTORY; boost::optional missing; { - ScopedLockType sll(mCompleteLock); + std::lock_guard sll(mCompleteLock); missing = prevMissing(mCompleteLedgers, mPubLedger->info().seq, app_.getNodeStore().earliestSeq()); diff --git a/src/ripple/app/ledger/impl/LocalTxs.cpp b/src/ripple/app/ledger/impl/LocalTxs.cpp index 67c77e701..2265559f6 100644 --- a/src/ripple/app/ledger/impl/LocalTxs.cpp +++ b/src/ripple/app/ledger/impl/LocalTxs.cpp @@ -115,7 +115,7 @@ public: // Add a new transaction to the set of local transactions void push_back (LedgerIndex index, std::shared_ptr const& txn) override { - std::lock_guard lock (m_lock); + std::lock_guard lock (m_lock); m_txns.emplace_back (index, txn); } @@ -128,7 +128,7 @@ public: // Get the set of local transactions as a canonical // set (so they apply in a valid order) { - std::lock_guard lock (m_lock); + std::lock_guard lock (m_lock); for (auto const& it : m_txns) tset.insert (it.getTX()); @@ -142,7 +142,7 @@ public: // or have expired void sweep (ReadView const& view) override { - std::lock_guard lock (m_lock); + std::lock_guard lock (m_lock); m_txns.remove_if ([&view](auto const& txn) { @@ -161,7 +161,7 @@ public: std::size_t size () override { - std::lock_guard lock (m_lock); + std::lock_guard lock (m_lock); return m_txns.size (); } diff --git a/src/ripple/app/ledger/impl/OpenLedger.cpp b/src/ripple/app/ledger/impl/OpenLedger.cpp index 829e62356..92cd053f6 100644 --- a/src/ripple/app/ledger/impl/OpenLedger.cpp +++ b/src/ripple/app/ledger/impl/OpenLedger.cpp @@ -44,33 +44,27 @@ OpenLedger::OpenLedger(std::shared_ptr< bool OpenLedger::empty() const { - std::lock_guard< - std::mutex> lock(modify_mutex_); + std::lock_guard lock(modify_mutex_); return current_->txCount() == 0; } std::shared_ptr OpenLedger::current() const { - std::lock_guard< - std::mutex> lock( - current_mutex_); + std::lock_guard lock(current_mutex_); return current_; } bool OpenLedger::modify (modify_type const& f) { - std::lock_guard< - std::mutex> lock1(modify_mutex_); + std::lock_guard lock1(modify_mutex_); auto next = std::make_shared< OpenView>(*current_); auto const changed = f(*next, j_); if (changed) { - std::lock_guard< - std::mutex> lock2( - current_mutex_); + std::lock_guard lock2(current_mutex_); current_ = std::move(next); } return changed; @@ -105,8 +99,7 @@ OpenLedger::accept(Application& app, Rules const& rules, // Block calls to modify, otherwise // new tx going into the open ledger // would get lost. - std::lock_guard< - std::mutex> lock1(modify_mutex_); + std::lock_guard lock1(modify_mutex_); // Apply tx from the current open view if (! current_->txs.empty()) { @@ -164,8 +157,7 @@ OpenLedger::accept(Application& app, Rules const& rules, } // Switch to the new open view - std::lock_guard< - std::mutex> lock2(current_mutex_); + std::lock_guard lock2(current_mutex_); current_ = std::move(next); } diff --git a/src/ripple/app/ledger/impl/TransactionAcquire.cpp b/src/ripple/app/ledger/impl/TransactionAcquire.cpp index 369ba153c..5386d1270 100644 --- a/src/ripple/app/ledger/impl/TransactionAcquire.cpp +++ b/src/ripple/app/ledger/impl/TransactionAcquire.cpp @@ -24,7 +24,7 @@ #include #include #include -#include + #include namespace ripple { diff --git a/src/ripple/app/main/Application.cpp b/src/ripple/app/main/Application.cpp index cbb57ebf2..b01bd4251 100644 --- a/src/ripple/app/main/Application.cpp +++ b/src/ripple/app/main/Application.cpp @@ -228,7 +228,7 @@ public: reset () override { { - std::lock_guard lock(maxSeqLock); + std::lock_guard lock(maxSeqLock); maxSeq = 0; } fullbelow_.reset(); @@ -1610,7 +1610,7 @@ ApplicationImp::signalStop() { // Unblock the main thread (which is sitting in run()). // - std::lock_guard lk{mut_}; + std::lock_guard lk{mut_}; isTimeToStop = true; cv_.notify_all(); } diff --git a/src/ripple/app/main/LoadManager.cpp b/src/ripple/app/main/LoadManager.cpp index c13924dd7..cc431bca9 100644 --- a/src/ripple/app/main/LoadManager.cpp +++ b/src/ripple/app/main/LoadManager.cpp @@ -59,14 +59,14 @@ LoadManager::~LoadManager () void LoadManager::activateDeadlockDetector () { - std::lock_guard sl (mutex_); + std::lock_guard sl (mutex_); armed_ = true; } void LoadManager::resetDeadlockDetector () { auto const elapsedSeconds = UptimeClock::now(); - std::lock_guard sl (mutex_); + std::lock_guard sl (mutex_); deadLock_ = elapsedSeconds; } @@ -90,7 +90,7 @@ void LoadManager::onStop () { JLOG(journal_.debug()) << "Stopping"; { - std::lock_guard sl (mutex_); + std::lock_guard sl (mutex_); stop_ = true; } thread_.join(); diff --git a/src/ripple/app/misc/HashRouter.cpp b/src/ripple/app/misc/HashRouter.cpp index 56beed1e3..e5af843b1 100644 --- a/src/ripple/app/misc/HashRouter.cpp +++ b/src/ripple/app/misc/HashRouter.cpp @@ -45,14 +45,14 @@ HashRouter::emplace (uint256 const& key) void HashRouter::addSuppression (uint256 const& key) { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); emplace (key); } bool HashRouter::addSuppressionPeer (uint256 const& key, PeerShortID peer) { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); auto result = emplace(key); result.first.addPeer(peer); @@ -61,7 +61,7 @@ bool HashRouter::addSuppressionPeer (uint256 const& key, PeerShortID peer) bool HashRouter::addSuppressionPeer (uint256 const& key, PeerShortID peer, int& flags) { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); auto result = emplace(key); auto& s = result.first; @@ -73,7 +73,7 @@ bool HashRouter::addSuppressionPeer (uint256 const& key, PeerShortID peer, int& bool HashRouter::shouldProcess (uint256 const& key, PeerShortID peer, int& flags, std::chrono::seconds tx_interval) { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); auto result = emplace(key); auto& s = result.first; @@ -84,7 +84,7 @@ bool HashRouter::shouldProcess (uint256 const& key, PeerShortID peer, int HashRouter::getFlags (uint256 const& key) { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); return emplace(key).first.getFlags (); } @@ -93,7 +93,7 @@ bool HashRouter::setFlags (uint256 const& key, int flags) { assert (flags != 0); - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); auto& s = emplace(key).first; @@ -108,7 +108,7 @@ auto HashRouter::shouldRelay (uint256 const& key) -> boost::optional> { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); auto& s = emplace(key).first; @@ -121,7 +121,7 @@ HashRouter::shouldRelay (uint256 const& key) bool HashRouter::shouldRecover(uint256 const& key) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); auto& s = emplace(key).first; diff --git a/src/ripple/app/misc/LoadFeeTrack.h b/src/ripple/app/misc/LoadFeeTrack.h index 321830d59..465d4e633 100644 --- a/src/ripple/app/misc/LoadFeeTrack.h +++ b/src/ripple/app/misc/LoadFeeTrack.h @@ -56,25 +56,25 @@ public: void setRemoteFee (std::uint32_t f) { - std::lock_guard sl (lock_); + std::lock_guard sl (lock_); remoteTxnLoadFee_ = f; } std::uint32_t getRemoteFee () const { - std::lock_guard sl (lock_); + std::lock_guard sl (lock_); return remoteTxnLoadFee_; } std::uint32_t getLocalFee () const { - std::lock_guard sl (lock_); + std::lock_guard sl (lock_); return localTxnLoadFee_; } std::uint32_t getClusterFee () const { - std::lock_guard sl (lock_); + std::lock_guard sl (lock_); return clusterTxnLoadFee_; } @@ -85,14 +85,14 @@ public: std::uint32_t getLoadFactor () const { - std::lock_guard sl (lock_); + std::lock_guard sl (lock_); return std::max({ clusterTxnLoadFee_, localTxnLoadFee_, remoteTxnLoadFee_ }); } std::pair getScalingFactors() const { - std::lock_guard sl(lock_); + std::lock_guard sl(lock_); return std::make_pair( std::max(localTxnLoadFee_, remoteTxnLoadFee_), @@ -102,7 +102,7 @@ public: void setClusterFee (std::uint32_t fee) { - std::lock_guard sl (lock_); + std::lock_guard sl (lock_); clusterTxnLoadFee_ = fee; } @@ -111,13 +111,13 @@ public: bool isLoadedLocal () const { - std::lock_guard sl (lock_); + std::lock_guard sl (lock_); return (raiseCount_ != 0) || (localTxnLoadFee_ != lftNormalFee); } bool isLoadedCluster () const { - std::lock_guard sl (lock_); + std::lock_guard sl (lock_); return (raiseCount_ != 0) || (localTxnLoadFee_ != lftNormalFee) || (clusterTxnLoadFee_ != lftNormalFee); } diff --git a/src/ripple/app/misc/Manifest.h b/src/ripple/app/misc/Manifest.h index 6635360d9..efc425fe2 100644 --- a/src/ripple/app/misc/Manifest.h +++ b/src/ripple/app/misc/Manifest.h @@ -346,7 +346,7 @@ public: void for_each_manifest(Function&& f) const { - std::lock_guard lock{read_mutex_}; + std::lock_guard lock{read_mutex_}; for (auto const& m : map_) { f(m.second); @@ -371,7 +371,7 @@ public: void for_each_manifest(PreFun&& pf, EachFun&& f) const { - std::lock_guard lock{read_mutex_}; + std::lock_guard lock{read_mutex_}; pf(map_.size ()); for (auto const& m : map_) { diff --git a/src/ripple/app/misc/NetworkOPs.cpp b/src/ripple/app/misc/NetworkOPs.cpp index ddf0031b5..9ed9b3b6e 100644 --- a/src/ripple/app/misc/NetworkOPs.cpp +++ b/src/ripple/app/misc/NetworkOPs.cpp @@ -57,9 +57,10 @@ #include #include #include -#include #include #include + +#include #include #include #include @@ -540,9 +541,6 @@ private: using SubInfoMapType = hash_map ; using subRpcMapType = hash_map; - // XXX Split into more locks. - using ScopedLockType = std::lock_guard ; - Application& app_; clock_type& m_clock; beast::Journal m_journal; @@ -725,7 +723,7 @@ void NetworkOPsImp::setClusterTimer () void NetworkOPsImp::processHeartbeatTimer () { { - auto lock = make_lock(app_.getMasterMutex()); + std::unique_lock lock{app_.getMasterMutex()}; // VFALCO NOTE This is for diagnosing a crash on exit LoadManager& mgr (app_.getLoadManager ()); @@ -942,7 +940,7 @@ void NetworkOPsImp::processTransaction (std::shared_ptr& transactio void NetworkOPsImp::doTransactionAsync (std::shared_ptr transaction, bool bUnlimited, FailHard failType) { - std::lock_guard lock (mMutex); + std::lock_guard lock (mMutex); if (transaction->getApplying()) return; @@ -1026,10 +1024,10 @@ void NetworkOPsImp::apply (std::unique_lock& batchLock) batchLock.unlock(); { - auto masterLock = make_lock(app_.getMasterMutex(), std::defer_lock); + std::unique_lock masterLock{app_.getMasterMutex(), std::defer_lock}; bool changed = false; { - auto ledgerLock = make_lock(m_ledgerMaster.peekMutex(), std::defer_lock); + std::unique_lock ledgerLock{m_ledgerMaster.peekMutex(), std::defer_lock}; std::lock(masterLock, ledgerLock); app_.openLedger().modify( @@ -1566,7 +1564,7 @@ void NetworkOPsImp::consensusViewChange () void NetworkOPsImp::pubManifest (Manifest const& mo) { // VFALCO consider std::shared_mutex - ScopedLockType sl (mSubLock); + std::lock_guard sl (mSubLock); if (!mStreamMaps[sManifests].empty ()) { @@ -1637,7 +1635,7 @@ void NetworkOPsImp::pubServer () // list into a local array while holding the lock then release the // lock and call send on everyone. // - ScopedLockType sl (mSubLock); + std::lock_guard sl (mSubLock); if (!mStreamMaps[sServer].empty ()) { @@ -1707,7 +1705,7 @@ void NetworkOPsImp::pubServer () void NetworkOPsImp::pubValidation (STValidation::ref val) { // VFALCO consider std::shared_mutex - ScopedLockType sl (mSubLock); + std::lock_guard sl (mSubLock); if (!mStreamMaps[sValidations].empty ()) { @@ -1767,7 +1765,7 @@ void NetworkOPsImp::pubValidation (STValidation::ref val) void NetworkOPsImp::pubPeerStatus ( std::function const& func) { - ScopedLockType sl (mSubLock); + std::lock_guard sl (mSubLock); if (!mStreamMaps[sPeerStatus].empty ()) { @@ -2396,7 +2394,7 @@ void NetworkOPsImp::pubProposedTransaction ( Json::Value jvObj = transJson (*stTxn, terResult, false, lpCurrent); { - ScopedLockType sl (mSubLock); + std::lock_guard sl (mSubLock); auto it = mStreamMaps[sRTTransactions].begin (); while (it != mStreamMaps[sRTTransactions].end ()) @@ -2437,7 +2435,7 @@ void NetworkOPsImp::pubLedger ( } { - ScopedLockType sl (mSubLock); + std::lock_guard sl (mSubLock); if (!mStreamMaps[sLedger].empty ()) { @@ -2571,7 +2569,7 @@ void NetworkOPsImp::pubValidatedTransaction ( } { - ScopedLockType sl (mSubLock); + std::lock_guard sl (mSubLock); auto it = mStreamMaps[sTransactions].begin (); while (it != mStreamMaps[sTransactions].end ()) @@ -2616,7 +2614,7 @@ void NetworkOPsImp::pubAccountTransaction ( int iAccepted = 0; { - ScopedLockType sl (mSubLock); + std::lock_guard sl (mSubLock); if (!bAccepted && mSubRTAccount.empty ()) return; @@ -2713,7 +2711,7 @@ void NetworkOPsImp::subAccount ( isrListener->insertSubAccountInfo (naAccountID, rt); } - ScopedLockType sl (mSubLock); + std::lock_guard sl (mSubLock); for (auto const& naAccountID : vnaAccountIDs) { @@ -2755,7 +2753,7 @@ void NetworkOPsImp::unsubAccountInternal ( hash_set const& vnaAccountIDs, bool rt) { - ScopedLockType sl (mSubLock); + std::lock_guard sl (mSubLock); SubInfoMapType& subMap = rt ? mSubRTAccount : mSubAccount; @@ -2833,7 +2831,7 @@ bool NetworkOPsImp::subLedger (InfoSub::ref isrListener, Json::Value& jvResult) = app_.getLedgerMaster ().getCompleteLedgers (); } - ScopedLockType sl (mSubLock); + std::lock_guard sl (mSubLock); return mStreamMaps[sLedger].emplace ( isrListener->getSeq (), isrListener).second; } @@ -2841,14 +2839,14 @@ bool NetworkOPsImp::subLedger (InfoSub::ref isrListener, Json::Value& jvResult) // <-- bool: true=erased, false=was not there bool NetworkOPsImp::unsubLedger (std::uint64_t uSeq) { - ScopedLockType sl (mSubLock); + std::lock_guard sl (mSubLock); return mStreamMaps[sLedger].erase (uSeq); } // <-- bool: true=added, false=already there bool NetworkOPsImp::subManifests (InfoSub::ref isrListener) { - ScopedLockType sl (mSubLock); + std::lock_guard sl (mSubLock); return mStreamMaps[sManifests].emplace ( isrListener->getSeq (), isrListener).second; } @@ -2856,7 +2854,7 @@ bool NetworkOPsImp::subManifests (InfoSub::ref isrListener) // <-- bool: true=erased, false=was not there bool NetworkOPsImp::unsubManifests (std::uint64_t uSeq) { - ScopedLockType sl (mSubLock); + std::lock_guard sl (mSubLock); return mStreamMaps[sManifests].erase (uSeq); } @@ -2885,7 +2883,7 @@ bool NetworkOPsImp::subServer (InfoSub::ref isrListener, Json::Value& jvResult, TokenType::NodePublic, app_.nodeIdentity().first); - ScopedLockType sl (mSubLock); + std::lock_guard sl (mSubLock); return mStreamMaps[sServer].emplace ( isrListener->getSeq (), isrListener).second; } @@ -2893,14 +2891,14 @@ bool NetworkOPsImp::subServer (InfoSub::ref isrListener, Json::Value& jvResult, // <-- bool: true=erased, false=was not there bool NetworkOPsImp::unsubServer (std::uint64_t uSeq) { - ScopedLockType sl (mSubLock); + std::lock_guard sl (mSubLock); return mStreamMaps[sServer].erase (uSeq); } // <-- bool: true=added, false=already there bool NetworkOPsImp::subTransactions (InfoSub::ref isrListener) { - ScopedLockType sl (mSubLock); + std::lock_guard sl (mSubLock); return mStreamMaps[sTransactions].emplace ( isrListener->getSeq (), isrListener).second; } @@ -2908,14 +2906,14 @@ bool NetworkOPsImp::subTransactions (InfoSub::ref isrListener) // <-- bool: true=erased, false=was not there bool NetworkOPsImp::unsubTransactions (std::uint64_t uSeq) { - ScopedLockType sl (mSubLock); + std::lock_guard sl (mSubLock); return mStreamMaps[sTransactions].erase (uSeq); } // <-- bool: true=added, false=already there bool NetworkOPsImp::subRTTransactions (InfoSub::ref isrListener) { - ScopedLockType sl (mSubLock); + std::lock_guard sl (mSubLock); return mStreamMaps[sRTTransactions].emplace ( isrListener->getSeq (), isrListener).second; } @@ -2923,14 +2921,14 @@ bool NetworkOPsImp::subRTTransactions (InfoSub::ref isrListener) // <-- bool: true=erased, false=was not there bool NetworkOPsImp::unsubRTTransactions (std::uint64_t uSeq) { - ScopedLockType sl (mSubLock); + std::lock_guard sl (mSubLock); return mStreamMaps[sRTTransactions].erase (uSeq); } // <-- bool: true=added, false=already there bool NetworkOPsImp::subValidations (InfoSub::ref isrListener) { - ScopedLockType sl (mSubLock); + std::lock_guard sl (mSubLock); return mStreamMaps[sValidations].emplace ( isrListener->getSeq (), isrListener).second; } @@ -2938,14 +2936,14 @@ bool NetworkOPsImp::subValidations (InfoSub::ref isrListener) // <-- bool: true=erased, false=was not there bool NetworkOPsImp::unsubValidations (std::uint64_t uSeq) { - ScopedLockType sl (mSubLock); + std::lock_guard sl (mSubLock); return mStreamMaps[sValidations].erase (uSeq); } // <-- bool: true=added, false=already there bool NetworkOPsImp::subPeerStatus (InfoSub::ref isrListener) { - ScopedLockType sl (mSubLock); + std::lock_guard sl (mSubLock); return mStreamMaps[sPeerStatus].emplace ( isrListener->getSeq (), isrListener).second; } @@ -2953,13 +2951,13 @@ bool NetworkOPsImp::subPeerStatus (InfoSub::ref isrListener) // <-- bool: true=erased, false=was not there bool NetworkOPsImp::unsubPeerStatus (std::uint64_t uSeq) { - ScopedLockType sl (mSubLock); + std::lock_guard sl (mSubLock); return mStreamMaps[sPeerStatus].erase (uSeq); } InfoSub::pointer NetworkOPsImp::findRpcSub (std::string const& strUrl) { - ScopedLockType sl (mSubLock); + std::lock_guard sl (mSubLock); subRpcMapType::iterator it = mRpcSubMap.find (strUrl); @@ -2972,7 +2970,7 @@ InfoSub::pointer NetworkOPsImp::findRpcSub (std::string const& strUrl) InfoSub::pointer NetworkOPsImp::addRpcSub ( std::string const& strUrl, InfoSub::ref rspEntry) { - ScopedLockType sl (mSubLock); + std::lock_guard sl (mSubLock); mRpcSubMap.emplace (strUrl, rspEntry); @@ -2981,7 +2979,7 @@ InfoSub::pointer NetworkOPsImp::addRpcSub ( bool NetworkOPsImp::tryRemoveRpcSub (std::string const& strUrl) { - ScopedLockType sl (mSubLock); + std::lock_guard sl (mSubLock); auto pInfo = findRpcSub(strUrl); if (!pInfo) @@ -3358,7 +3356,7 @@ void NetworkOPsImp::StateAccounting::mode (OperatingMode om) { auto now = std::chrono::system_clock::now(); - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); ++counters_[om].transitions; counters_[mode_].dur += std::chrono::duration_cast< std::chrono::microseconds>(now - start_); diff --git a/src/ripple/app/misc/SHAMapStoreImp.cpp b/src/ripple/app/misc/SHAMapStoreImp.cpp index 5f4a06a7e..c11a0221d 100644 --- a/src/ripple/app/misc/SHAMapStoreImp.cpp +++ b/src/ripple/app/misc/SHAMapStoreImp.cpp @@ -31,7 +31,7 @@ namespace ripple { void SHAMapStoreImp::SavedStateDB::init (BasicConfig const& config, std::string const& dbName) { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); open(session_, config, dbName); @@ -92,7 +92,7 @@ LedgerIndex SHAMapStoreImp::SavedStateDB::getCanDelete() { LedgerIndex seq; - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); session_ << "SELECT CanDeleteSeq FROM CanDelete WHERE Key = 1;" @@ -105,7 +105,7 @@ SHAMapStoreImp::SavedStateDB::getCanDelete() LedgerIndex SHAMapStoreImp::SavedStateDB::setCanDelete (LedgerIndex canDelete) { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); session_ << "UPDATE CanDelete SET CanDeleteSeq = :canDelete WHERE Key = 1;" @@ -120,7 +120,7 @@ SHAMapStoreImp::SavedStateDB::getState() { SavedState state; - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); session_ << "SELECT WritableDb, ArchiveDb, LastRotatedLedger" @@ -135,7 +135,7 @@ SHAMapStoreImp::SavedStateDB::getState() void SHAMapStoreImp::SavedStateDB::setState (SavedState const& state) { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); session_ << "UPDATE DbState" " SET WritableDb = :writableDb," @@ -151,7 +151,7 @@ SHAMapStoreImp::SavedStateDB::setState (SavedState const& state) void SHAMapStoreImp::SavedStateDB::setLastRotated (LedgerIndex seq) { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); session_ << "UPDATE DbState SET LastRotatedLedger = :seq" " WHERE Key = 1;" @@ -277,7 +277,7 @@ SHAMapStoreImp::onLedgerClosed( std::shared_ptr const& ledger) { { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); newLedger_ = ledger; working_ = true; } @@ -451,7 +451,7 @@ SHAMapStoreImp::run() lastRotated = validatedSeq; std::unique_ptr oldBackend; { - std::lock_guard lock (dbRotating_->peekMutex()); + std::lock_guard lock (dbRotating_->peekMutex()); state_db_.setState (SavedState {newBackend->getName(), nextArchiveDir, lastRotated}); @@ -646,7 +646,7 @@ SHAMapStoreImp::Health SHAMapStoreImp::health() { { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); if (stop_) return Health::stopping; } @@ -676,7 +676,7 @@ SHAMapStoreImp::onStop() if (deleteInterval_) { { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); stop_ = true; } cond_.notify_one(); @@ -693,7 +693,7 @@ SHAMapStoreImp::onChildrenStopped() if (deleteInterval_) { { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); stop_ = true; } cond_.notify_one(); diff --git a/src/ripple/app/misc/impl/AmendmentTable.cpp b/src/ripple/app/misc/impl/AmendmentTable.cpp index 51a79a056..1279ca441 100644 --- a/src/ripple/app/misc/impl/AmendmentTable.cpp +++ b/src/ripple/app/misc/impl/AmendmentTable.cpp @@ -231,7 +231,7 @@ AmendmentTableImpl::AmendmentTableImpl ( { assert (majorityFraction_ != 0); - std::lock_guard sl (mutex_); + std::lock_guard sl (mutex_); for (auto const& a : parseSection(supported)) { @@ -300,7 +300,7 @@ AmendmentTableImpl::get (uint256 const& amendmentHash) uint256 AmendmentTableImpl::find (std::string const& name) { - std::lock_guard sl (mutex_); + std::lock_guard sl (mutex_); for (auto const& e : amendmentMap_) { @@ -314,7 +314,7 @@ AmendmentTableImpl::find (std::string const& name) bool AmendmentTableImpl::veto (uint256 const& amendment) { - std::lock_guard sl (mutex_); + std::lock_guard sl (mutex_); auto s = add (amendment); if (s->vetoed) @@ -326,7 +326,7 @@ AmendmentTableImpl::veto (uint256 const& amendment) bool AmendmentTableImpl::unVeto (uint256 const& amendment) { - std::lock_guard sl (mutex_); + std::lock_guard sl (mutex_); auto s = get (amendment); if (!s || !s->vetoed) @@ -338,7 +338,7 @@ AmendmentTableImpl::unVeto (uint256 const& amendment) bool AmendmentTableImpl::enable (uint256 const& amendment) { - std::lock_guard sl (mutex_); + std::lock_guard sl (mutex_); auto s = add (amendment); if (s->enabled) @@ -359,7 +359,7 @@ AmendmentTableImpl::enable (uint256 const& amendment) bool AmendmentTableImpl::disable (uint256 const& amendment) { - std::lock_guard sl (mutex_); + std::lock_guard sl (mutex_); auto s = get (amendment); if (!s || !s->enabled) @@ -372,7 +372,7 @@ AmendmentTableImpl::disable (uint256 const& amendment) bool AmendmentTableImpl::isEnabled (uint256 const& amendment) { - std::lock_guard sl (mutex_); + std::lock_guard sl (mutex_); auto s = get (amendment); return s && s->enabled; } @@ -380,7 +380,7 @@ AmendmentTableImpl::isEnabled (uint256 const& amendment) bool AmendmentTableImpl::isSupported (uint256 const& amendment) { - std::lock_guard sl (mutex_); + std::lock_guard sl (mutex_); auto s = get (amendment); return s && s->supported; } @@ -388,7 +388,7 @@ AmendmentTableImpl::isSupported (uint256 const& amendment) bool AmendmentTableImpl::hasUnsupportedEnabled () { - std::lock_guard sl (mutex_); + std::lock_guard sl (mutex_); return unsupportedEnabled_; } @@ -402,7 +402,7 @@ AmendmentTableImpl::doValidation ( amendments.reserve (amendmentMap_.size()); { - std::lock_guard sl (mutex_); + std::lock_guard sl (mutex_); for (auto const& e : amendmentMap_) { if (e.second.supported && ! e.second.vetoed && @@ -471,7 +471,7 @@ AmendmentTableImpl::doVoting ( std::map actions; { - std::lock_guard sl (mutex_); + std::lock_guard sl (mutex_); // process all amendments we know of for (auto const& entry : amendmentMap_) @@ -530,7 +530,7 @@ AmendmentTableImpl::doVoting ( bool AmendmentTableImpl::needValidatedLedger (LedgerIndex ledgerSeq) { - std::lock_guard sl (mutex_); + std::lock_guard sl (mutex_); // Is there a ledger in which an amendment could have been enabled // between these two ledger sequences? @@ -579,7 +579,7 @@ AmendmentTableImpl::getJson (int) { Json::Value ret(Json::objectValue); { - std::lock_guard sl(mutex_); + std::lock_guard sl(mutex_); for (auto const& e : amendmentMap_) { setJson (ret[to_string (e.first)] = Json::objectValue, @@ -596,7 +596,7 @@ AmendmentTableImpl::getJson (uint256 const& amendmentID) Json::Value& jAmendment = (ret[to_string (amendmentID)] = Json::objectValue); { - std::lock_guard sl(mutex_); + std::lock_guard sl(mutex_); auto a = add (amendmentID); setJson (jAmendment, amendmentID, *a); } diff --git a/src/ripple/app/misc/impl/LoadFeeTrack.cpp b/src/ripple/app/misc/impl/LoadFeeTrack.cpp index b4f3631a2..cc144c7e4 100644 --- a/src/ripple/app/misc/impl/LoadFeeTrack.cpp +++ b/src/ripple/app/misc/impl/LoadFeeTrack.cpp @@ -33,7 +33,7 @@ namespace ripple { bool LoadFeeTrack::raiseLocalFee () { - std::lock_guard sl (lock_); + std::lock_guard sl (lock_); if (++raiseCount_ < 2) return false; @@ -61,7 +61,7 @@ LoadFeeTrack::raiseLocalFee () bool LoadFeeTrack::lowerLocalFee () { - std::lock_guard sl (lock_); + std::lock_guard sl (lock_); std::uint32_t origFee = localTxnLoadFee_; raiseCount_ = 0; diff --git a/src/ripple/app/misc/impl/Manifest.cpp b/src/ripple/app/misc/impl/Manifest.cpp index 94adf516a..fc19f50af 100644 --- a/src/ripple/app/misc/impl/Manifest.cpp +++ b/src/ripple/app/misc/impl/Manifest.cpp @@ -288,7 +288,7 @@ ValidatorToken::make_ValidatorToken(std::vector const& tokenBlob) PublicKey ManifestCache::getSigningKey (PublicKey const& pk) const { - std::lock_guard lock{read_mutex_}; + std::lock_guard lock{read_mutex_}; auto const iter = map_.find (pk); if (iter != map_.end () && !iter->second.revoked ()) @@ -300,7 +300,7 @@ ManifestCache::getSigningKey (PublicKey const& pk) const PublicKey ManifestCache::getMasterKey (PublicKey const& pk) const { - std::lock_guard lock{read_mutex_}; + std::lock_guard lock{read_mutex_}; auto const iter = signingToMasterKeys_.find (pk); if (iter != signingToMasterKeys_.end ()) @@ -312,7 +312,7 @@ ManifestCache::getMasterKey (PublicKey const& pk) const bool ManifestCache::revoked (PublicKey const& pk) const { - std::lock_guard lock{read_mutex_}; + std::lock_guard lock{read_mutex_}; auto const iter = map_.find (pk); if (iter != map_.end ()) @@ -324,7 +324,7 @@ ManifestCache::revoked (PublicKey const& pk) const ManifestDisposition ManifestCache::applyManifest (Manifest m) { - std::lock_guard applyLock{apply_mutex_}; + std::lock_guard applyLock{apply_mutex_}; /* before we spend time checking the signature, make sure the @@ -357,7 +357,7 @@ ManifestCache::applyManifest (Manifest m) return ManifestDisposition::invalid; } - std::lock_guard readLock{read_mutex_}; + std::lock_guard readLock{read_mutex_}; bool const revoked = m.revoked(); @@ -508,7 +508,7 @@ void ManifestCache::save ( DatabaseCon& dbCon, std::string const& dbTable, std::function isTrusted) { - std::lock_guard lock{apply_mutex_}; + std::lock_guard lock{apply_mutex_}; auto db = dbCon.checkoutDb (); diff --git a/src/ripple/app/misc/impl/TxQ.cpp b/src/ripple/app/misc/impl/TxQ.cpp index 2d3029af4..0b36b9607 100644 --- a/src/ripple/app/misc/impl/TxQ.cpp +++ b/src/ripple/app/misc/impl/TxQ.cpp @@ -660,7 +660,7 @@ TxQ::apply(Application& app, OpenView& view, boost::optional consequences; boost::optional replacedItemDeleteIter; - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); auto const metricsSnapshot = feeMetrics_.getSnapshot(); @@ -1184,7 +1184,7 @@ void TxQ::processClosedLedger(Application& app, ReadView const& view, bool timeLeap) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); feeMetrics_.update(app, view, timeLeap, setup_); auto const& snapshot = feeMetrics_.getSnapshot(); @@ -1266,7 +1266,7 @@ TxQ::accept(Application& app, auto ledgerChanged = false; - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); auto const metricSnapshot = feeMetrics_.getSnapshot(); @@ -1380,7 +1380,7 @@ TxQ::getMetrics(OpenView const& view) const { Metrics result; - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); auto const snapshot = feeMetrics_.getSnapshot(); @@ -1401,7 +1401,7 @@ auto TxQ::getAccountTxs(AccountID const& account, ReadView const& view) const -> std::map { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); auto accountIter = byAccount_.find(account); if (accountIter == byAccount_.end() || @@ -1430,7 +1430,7 @@ auto TxQ::getTxs(ReadView const& view) const -> std::vector { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (byFee_.empty()) return {}; diff --git a/src/ripple/app/misc/impl/ValidatorSite.cpp b/src/ripple/app/misc/impl/ValidatorSite.cpp index 93426b449..20ea3bfe4 100644 --- a/src/ripple/app/misc/impl/ValidatorSite.cpp +++ b/src/ripple/app/misc/impl/ValidatorSite.cpp @@ -127,7 +127,7 @@ ValidatorSite::load ( JLOG (j_.debug()) << "Loading configured validator list sites"; - std::lock_guard lock{sites_mutex_}; + std::lock_guard lock{sites_mutex_}; for (auto const& uri : siteURIs) { @@ -153,7 +153,7 @@ ValidatorSite::load ( void ValidatorSite::start () { - std::lock_guard lock{state_mutex_}; + std::lock_guard lock{state_mutex_}; if (timer_.expires_at() == clock_type::time_point{}) setTimer (lock); } @@ -194,7 +194,7 @@ ValidatorSite::stop() void ValidatorSite::setTimer (std::lock_guard& state_lock) { - std::lock_guard lock{sites_mutex_}; + std::lock_guard lock{sites_mutex_}; auto next = std::min_element(sites_.begin(), sites_.end(), [](Site const& a, Site const& b) @@ -227,7 +227,7 @@ ValidatorSite::makeRequest ( auto timeoutCancel = [this] () { - std::lock_guard lock_state{state_mutex_}; + std::lock_guard lock_state{state_mutex_}; // docs indicate cancel_one() can throw, but this // should be reconsidered if it changes to noexcept try @@ -288,7 +288,7 @@ ValidatorSite::makeRequest ( sp->run (); // start a timer for the request, which shouldn't take more // than requestTimeout_ to complete - std::lock_guard lock_state{state_mutex_}; + std::lock_guard lock_state{state_mutex_}; timer_.expires_after (requestTimeout_); timer_.async_wait ([this, siteIdx] (boost::system::error_code const& ec) { @@ -305,13 +305,13 @@ ValidatorSite::onRequestTimeout ( return; { - std::lock_guard lock_site{sites_mutex_}; + std::lock_guard lock_site{sites_mutex_}; JLOG (j_.warn()) << "Request for " << sites_[siteIdx].activeResource->uri << " took too long"; } - std::lock_guard lock_state{state_mutex_}; + std::lock_guard lock_state{state_mutex_}; if(auto sp = work_.lock()) sp->cancel(); } @@ -332,7 +332,7 @@ ValidatorSite::onTimer ( try { - std::lock_guard lock{sites_mutex_}; + std::lock_guard lock{sites_mutex_}; sites_[siteIdx].nextRefresh = clock_type::now() + sites_[siteIdx].refreshInterval; sites_[siteIdx].redirCount = 0; @@ -499,7 +499,7 @@ ValidatorSite::onSiteFetch( std::size_t siteIdx) { { - std::lock_guard lock_sites{sites_mutex_}; + std::lock_guard lock_sites{sites_mutex_}; JLOG (j_.debug()) << "Got completion for " << sites_[siteIdx].activeResource->uri; auto onError = [&](std::string const& errMsg, bool retry) @@ -570,7 +570,7 @@ ValidatorSite::onSiteFetch( sites_[siteIdx].activeResource.reset(); } - std::lock_guard lock_state{state_mutex_}; + std::lock_guard lock_state{state_mutex_}; fetching_ = false; if (! stopping_) setTimer (lock_state); @@ -584,7 +584,7 @@ ValidatorSite::onTextFetch( std::size_t siteIdx) { { - std::lock_guard lock_sites{sites_mutex_}; + std::lock_guard lock_sites{sites_mutex_}; try { if (ec) @@ -611,7 +611,7 @@ ValidatorSite::onTextFetch( sites_[siteIdx].activeResource.reset(); } - std::lock_guard lock_state{state_mutex_}; + std::lock_guard lock_state{state_mutex_}; fetching_ = false; if (! stopping_) setTimer (lock_state); @@ -627,7 +627,7 @@ ValidatorSite::getJson() const Json::Value jrr(Json::objectValue); Json::Value& jSites = (jrr[jss::validator_sites] = Json::arrayValue); { - std::lock_guard lock{sites_mutex_}; + std::lock_guard lock{sites_mutex_}; for (Site const& site : sites_) { Json::Value& v = jSites.append(Json::objectValue); diff --git a/src/ripple/app/paths/PathRequest.cpp b/src/ripple/app/paths/PathRequest.cpp index d08f1c28a..972ad7a32 100644 --- a/src/ripple/app/paths/PathRequest.cpp +++ b/src/ripple/app/paths/PathRequest.cpp @@ -113,7 +113,7 @@ PathRequest::~PathRequest() bool PathRequest::isNew () { - ScopedLockType sl (mIndexLock); + std::lock_guard sl (mIndexLock); // does this path request still need its first full path return mLastIndex == 0; @@ -121,7 +121,7 @@ bool PathRequest::isNew () bool PathRequest::needsUpdate (bool newOnly, LedgerIndex index) { - ScopedLockType sl (mIndexLock); + std::lock_guard sl (mIndexLock); if (mInProgress) { @@ -151,7 +151,7 @@ bool PathRequest::hasCompletion () void PathRequest::updateComplete () { - ScopedLockType sl (mIndexLock); + std::lock_guard sl (mIndexLock); assert (mInProgress); mInProgress = false; @@ -443,14 +443,14 @@ int PathRequest::parseJson (Json::Value const& jvParams) Json::Value PathRequest::doClose (Json::Value const&) { JLOG(m_journal.debug()) << iIdentifier << " closed"; - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); jvStatus[jss::closed] = true; return jvStatus; } Json::Value PathRequest::doStatus (Json::Value const&) { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); jvStatus[jss::status] = jss::success; return jvStatus; } @@ -626,7 +626,7 @@ Json::Value PathRequest::doUpdate( << " update " << (fast ? "fast" : "normal"); { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); if (!isValid (cache)) return jvStatus; @@ -712,7 +712,7 @@ Json::Value PathRequest::doUpdate( } { - ScopedLockType sl(mLock); + std::lock_guard sl(mLock); jvStatus = newStatus; } diff --git a/src/ripple/app/paths/PathRequest.h b/src/ripple/app/paths/PathRequest.h index 5d1c526ea..93f702bfc 100644 --- a/src/ripple/app/paths/PathRequest.h +++ b/src/ripple/app/paths/PathRequest.h @@ -101,7 +101,6 @@ public: bool hasCompletion (); private: - using ScopedLockType = std::lock_guard ; bool isValid (std::shared_ptr const& crCache); void setValid (); diff --git a/src/ripple/app/paths/PathRequests.cpp b/src/ripple/app/paths/PathRequests.cpp index dcfac65f0..b140a18ac 100644 --- a/src/ripple/app/paths/PathRequests.cpp +++ b/src/ripple/app/paths/PathRequests.cpp @@ -38,7 +38,7 @@ PathRequests::getLineCache ( std::shared_ptr const& ledger, bool authoritative) { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); std::uint32_t lineSeq = mLineCache ? mLineCache->getLedger()->seq() : 0; std::uint32_t lgrSeq = ledger->seq(); @@ -65,7 +65,7 @@ void PathRequests::updateAll (std::shared_ptr const& inLedger, // Get the ledger and cache we should be using { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); requests = requests_; cache = getLineCache (inLedger, true); } @@ -119,7 +119,7 @@ void PathRequests::updateAll (std::shared_ptr const& inLedger, if (remove) { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); // Remove any dangling weak pointers or weak // pointers that refer to this path request. @@ -165,7 +165,7 @@ void PathRequests::updateAll (std::shared_ptr const& inLedger, { // Get the latest requests, cache, and ledger for next pass - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); if (requests_.empty()) break; @@ -183,7 +183,7 @@ void PathRequests::updateAll (std::shared_ptr const& inLedger, void PathRequests::insertPathRequest ( PathRequest::pointer const& req) { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); // Insert after any older unserviced requests but before // any serviced requests diff --git a/src/ripple/app/paths/PathRequests.h b/src/ripple/app/paths/PathRequests.h index fb5cc614e..67ed74407 100644 --- a/src/ripple/app/paths/PathRequests.h +++ b/src/ripple/app/paths/PathRequests.h @@ -106,7 +106,6 @@ private: std::atomic mLastIdentifier; - 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 e9338a4d1..0697c7366 100644 --- a/src/ripple/app/paths/RippleLineCache.cpp +++ b/src/ripple/app/paths/RippleLineCache.cpp @@ -36,7 +36,7 @@ RippleLineCache::getRippleLines (AccountID const& accountID) { AccountKey key (accountID, hasher_ (accountID)); - std::lock_guard sl (mLock); + std::lock_guard sl (mLock); auto it = lines_.emplace (key, std::vector()); diff --git a/src/ripple/basics/KeyCache.h b/src/ripple/basics/KeyCache.h index bcdb5b693..70750537c 100644 --- a/src/ripple/basics/KeyCache.h +++ b/src/ripple/basics/KeyCache.h @@ -80,7 +80,6 @@ private: using map_type = hardened_hash_map ; using iterator = typename map_type::iterator; - using lock_guard = std::lock_guard ; public: using size_type = typename map_type::size_type; @@ -144,20 +143,20 @@ public: /** Returns the number of items in the container. */ size_type size () const { - lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); return m_map.size (); } /** Empty the cache */ void clear () { - lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); m_map.clear (); } void reset () { - lock_guard lock(m_mutex); + std::lock_guard lock(m_mutex); m_map.clear(); m_stats.hits = 0; m_stats.misses = 0; @@ -165,13 +164,13 @@ public: void setTargetSize (size_type s) { - lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); m_target_size = s; } void setTargetAge (std::chrono::seconds s) { - lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); m_target_age = s; } @@ -181,7 +180,7 @@ public: template bool exists (KeyComparable const& key) const { - lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); typename map_type::const_iterator const iter (m_map.find (key)); if (iter != m_map.end ()) { @@ -198,7 +197,7 @@ public: */ bool insert (Key const& key) { - lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); clock_type::time_point const now (m_clock.now ()); std::pair result (m_map.emplace ( std::piecewise_construct, std::forward_as_tuple (key), @@ -217,7 +216,7 @@ public: template bool touch_if_exists (KeyComparable const& key) { - lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); iterator const iter (m_map.find (key)); if (iter == m_map.end ()) { @@ -235,7 +234,7 @@ public: */ bool erase (key_type const& key) { - lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); if (m_map.erase (key) > 0) { ++m_stats.hits; @@ -251,7 +250,7 @@ public: clock_type::time_point const now (m_clock.now ()); clock_type::time_point when_expire; - lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); if (m_target_size == 0 || (m_map.size () <= m_target_size)) @@ -297,7 +296,7 @@ private: { beast::insight::Gauge::value_type hit_rate (0); { - lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); auto const total (m_stats.hits + m_stats.misses); if (total != 0) hit_rate = (m_stats.hits * 100) / total; diff --git a/src/ripple/basics/ScopedLock.h b/src/ripple/basics/ScopedLock.h index 41cd6d910..bbd1b04ae 100644 --- a/src/ripple/basics/ScopedLock.h +++ b/src/ripple/basics/ScopedLock.h @@ -42,7 +42,7 @@ namespace ripple for (;;) { - std::lock_guard myScopedLock{mut}; + std::lock_guard myScopedLock{mut}; // mut is now locked ... do some stuff with it locked .. diff --git a/src/ripple/basics/TaggedCache.h b/src/ripple/basics/TaggedCache.h index 0e74dc787..3ed6bd1c3 100644 --- a/src/ripple/basics/TaggedCache.h +++ b/src/ripple/basics/TaggedCache.h @@ -59,9 +59,6 @@ class TaggedCache { public: using mutex_type = Mutex; - // VFALCO DEPRECATED The caller can just use std::unique_lock - using ScopedLockType = std::unique_lock ; - using lock_guard = std::lock_guard ; using key_type = Key; using mapped_type = T; // VFALCO TODO Use std::shared_ptr, std::weak_ptr @@ -96,13 +93,13 @@ public: int getTargetSize () const { - lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); return m_target_size; } void setTargetSize (int s) { - lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); m_target_size = s; if (s > 0) @@ -114,13 +111,13 @@ public: clock_type::duration getTargetAge () const { - lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); return m_target_age; } void setTargetAge (clock_type::duration s) { - lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); m_target_age = s; JLOG(m_journal.debug()) << m_name << " target age set to " << m_target_age.count(); @@ -128,33 +125,33 @@ public: int getCacheSize () const { - lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); return m_cache_count; } int getTrackSize () const { - lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); return m_cache.size (); } float getHitRate () { - lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); auto const total = static_cast (m_hits + m_misses); return m_hits * (100.0f / std::max (1.0f, total)); } void clear () { - lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); m_cache.clear (); m_cache_count = 0; } void reset () { - lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); m_cache.clear(); m_cache_count = 0; m_hits = 0; @@ -176,7 +173,7 @@ public: clock_type::time_point const now (m_clock.now()); clock_type::time_point when_expire; - lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); if (m_target_size == 0 || (static_cast (m_cache.size ()) <= m_target_size)) @@ -257,7 +254,7 @@ public: bool del (const key_type& key, bool valid) { // Remove from cache, if !valid, remove from map too. Returns true if removed from cache - lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); cache_iterator cit = m_cache.find (key); @@ -298,7 +295,7 @@ public: { // Return canonical value, store if needed, refresh in cache // Return values: true=we had the data already - lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); cache_iterator cit = m_cache.find (key); @@ -358,7 +355,7 @@ public: std::shared_ptr fetch (const key_type& key) { // fetch us a shared pointer to the stored data object - lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); cache_iterator cit = m_cache.find (key); @@ -429,7 +426,7 @@ public: bool found = false; // If present, make current in cache - lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); cache_iterator cit = m_cache.find (key); @@ -481,7 +478,7 @@ public: std::vector v; { - lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); v.reserve (m_cache.size()); for (auto const& _ : m_cache) v.push_back (_.first); @@ -498,7 +495,7 @@ private: { beast::insight::Gauge::value_type hit_rate (0); { - lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); auto const total (m_hits + m_misses); if (total != 0) hit_rate = (m_hits * 100) / total; diff --git a/src/ripple/basics/hardened_hash.h b/src/ripple/basics/hardened_hash.h index 88c32698b..65b0b4ad2 100644 --- a/src/ripple/basics/hardened_hash.h +++ b/src/ripple/basics/hardened_hash.h @@ -65,7 +65,7 @@ make_seed_pair() noexcept // state_t& operator=(state_t const&) = delete; }; static state_t state; - std::lock_guard lock (state.mutex); + std::lock_guard lock(state.mutex); return {state.dist(state.gen), state.dist(state.gen)}; } diff --git a/src/ripple/basics/impl/Log.cpp b/src/ripple/basics/impl/Log.cpp index 3bd9ba6e2..923f52ca4 100644 --- a/src/ripple/basics/impl/Log.cpp +++ b/src/ripple/basics/impl/Log.cpp @@ -124,7 +124,7 @@ Logs::open (boost::filesystem::path const& pathToLogFile) beast::Journal::Sink& Logs::get (std::string const& name) { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); auto const result = sinks_.emplace(name, makeSink(name, thresh_)); return *result.first->second; @@ -151,7 +151,7 @@ Logs::threshold() const void Logs::threshold (beast::severities::Severity thresh) { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); thresh_ = thresh; for (auto& sink : sinks_) sink.second->threshold (thresh); @@ -161,7 +161,7 @@ std::vector> Logs::partition_severities() const { std::vector> list; - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); list.reserve (sinks_.size()); for (auto const& e : sinks_) list.push_back(std::make_pair(e.first, @@ -175,7 +175,7 @@ Logs::write (beast::severities::Severity level, std::string const& partition, { std::string s; format (s, text, level, partition); - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); file_.writeln (s); if (! silent_) std::cerr << s << '\n'; @@ -187,7 +187,7 @@ Logs::write (beast::severities::Severity level, std::string const& partition, std::string Logs::rotate() { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); bool const wasOpened = file_.closeAndReopen (); if (wasOpened) return "The log file was closed and reopened."; @@ -375,7 +375,7 @@ public: std::unique_ptr set(std::unique_ptr sink) { - std::lock_guard _(m_); + std::lock_guard _(m_); using std::swap; swap (holder_, sink); @@ -391,7 +391,7 @@ public: beast::Journal::Sink& get() { - std::lock_guard _(m_); + std::lock_guard _(m_); return sink_.get(); } }; diff --git a/src/ripple/basics/impl/PerfLogImp.cpp b/src/ripple/basics/impl/PerfLogImp.cpp index 308963d9f..e0f4a0244 100644 --- a/src/ripple/basics/impl/PerfLogImp.cpp +++ b/src/ripple/basics/impl/PerfLogImp.cpp @@ -81,7 +81,7 @@ PerfLogImp::Counters::countersJson() const { auto const sync = [&proc]() ->boost::optional { - std::lock_guard lock(proc.second.mut); + std::lock_guard lock(proc.second.mut); if (!proc.second.sync.started && !proc.second.sync.finished && !proc.second.sync.errored) @@ -125,7 +125,7 @@ PerfLogImp::Counters::countersJson() const { auto const sync = [&proc]() ->boost::optional { - std::lock_guard lock(proc.second.mut); + std::lock_guard lock(proc.second.mut); if (!proc.second.sync.queued && !proc.second.sync.started && !proc.second.sync.finished) @@ -181,7 +181,7 @@ PerfLogImp::Counters::currentJson() const Json::Value jobsArray(Json::arrayValue); auto const jobs = [this]{ - std::lock_guard lock(jobsMutex_); + std::lock_guard lock(jobsMutex_); return jobs_; }(); @@ -207,7 +207,7 @@ PerfLogImp::Counters::currentJson() const Json::Value methodsArray(Json::arrayValue); std::vector methods; { - std::lock_guard lock(methodsMutex_); + std::lock_guard lock(methodsMutex_); methods.reserve(methods_.size()); for (auto const& m : methods_) methods.push_back(m.second); @@ -339,10 +339,10 @@ PerfLogImp::rpcStart(std::string const& method, std::uint64_t const requestId) } { - std::lock_guard lock(counter->second.mut); + std::lock_guard lock(counter->second.mut); ++counter->second.sync.started; } - std::lock_guard lock(counters_.methodsMutex_); + std::lock_guard lock(counters_.methodsMutex_); counters_.methods_[requestId] = { counter->first.c_str(), steady_clock::now() @@ -362,7 +362,7 @@ PerfLogImp::rpcEnd(std::string const& method, } steady_time_point startTime; { - std::lock_guard lock(counters_.methodsMutex_); + std::lock_guard lock(counters_.methodsMutex_); auto const e = counters_.methods_.find(requestId); if (e != counters_.methods_.end()) { @@ -374,7 +374,7 @@ PerfLogImp::rpcEnd(std::string const& method, assert(false); } } - std::lock_guard lock(counter->second.mut); + std::lock_guard lock(counter->second.mut); if (finish) ++counter->second.sync.finished; else @@ -393,7 +393,7 @@ PerfLogImp::jobQueue(JobType const type) assert(false); return; } - std::lock_guard lock(counter->second.mut); + std::lock_guard lock(counter->second.mut); ++counter->second.sync.queued; } @@ -410,11 +410,11 @@ PerfLogImp::jobStart(JobType const type, return; } { - std::lock_guard lock(counter->second.mut); + std::lock_guard lock(counter->second.mut); ++counter->second.sync.started; counter->second.sync.queuedDuration += dur; } - std::lock_guard lock(counters_.jobsMutex_); + std::lock_guard lock(counters_.jobsMutex_); if (instance >= 0 && instance < counters_.jobs_.size()) counters_.jobs_[instance] = {type, startTime}; } @@ -430,11 +430,11 @@ PerfLogImp::jobFinish(JobType const type, microseconds dur, return; } { - std::lock_guard lock(counter->second.mut); + std::lock_guard lock(counter->second.mut); ++counter->second.sync.finished; counter->second.sync.runningDuration += dur; } - std::lock_guard lock(counters_.jobsMutex_); + std::lock_guard lock(counters_.jobsMutex_); if (instance >= 0 && instance < counters_.jobs_.size()) counters_.jobs_[instance] = {jtINVALID, steady_time_point()}; } @@ -442,7 +442,7 @@ PerfLogImp::jobFinish(JobType const type, microseconds dur, void PerfLogImp::resizeJobs(int const resize) { - std::lock_guard lock(counters_.jobsMutex_); + std::lock_guard lock(counters_.jobsMutex_); counters_.workers_ = resize; if (resize > counters_.jobs_.size()) counters_.jobs_.resize(resize, {jtINVALID, steady_time_point()}); @@ -455,7 +455,7 @@ PerfLogImp::rotate() if (setup_.perfLog.empty()) return; - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); rotate_ = true; cond_.notify_one(); } @@ -473,7 +473,7 @@ PerfLogImp::onStop() if (thread_.joinable()) { { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); stop_ = true; cond_.notify_one(); } diff --git a/src/ripple/basics/impl/ResolverAsio.cpp b/src/ripple/basics/impl/ResolverAsio.cpp index e60b12504..3a0581260 100644 --- a/src/ripple/basics/impl/ResolverAsio.cpp +++ b/src/ripple/basics/impl/ResolverAsio.cpp @@ -179,7 +179,7 @@ public: if (m_stopped.exchange (false) == true) { { - std::lock_guard lk{m_mut}; + std::lock_guard lk{m_mut}; m_asyncHandlersCompleted = false; } addReference (); diff --git a/src/ripple/basics/impl/make_SSLContext.cpp b/src/ripple/basics/impl/make_SSLContext.cpp index 0935010b9..fac4d2f3e 100644 --- a/src/ripple/basics/impl/make_SSLContext.cpp +++ b/src/ripple/basics/impl/make_SSLContext.cpp @@ -202,7 +202,7 @@ disallowRenegotiation (SSL const* ssl, bool isNew) }; static StaticData sd; - std::lock_guard lock (sd.lock); + std::lock_guard lock (sd.lock); auto const expired (sd.set.clock().now() - std::chrono::minutes(4)); // Remove expired entries diff --git a/src/ripple/basics/make_lock.h b/src/ripple/basics/make_lock.h deleted file mode 100644 index 05724eaca..000000000 --- a/src/ripple/basics/make_lock.h +++ /dev/null @@ -1,38 +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_MAKE_LOCK_H_INCLUDED -#define RIPPLE_BASICS_MAKE_LOCK_H_INCLUDED - -#include -#include - -namespace ripple { - -template -inline -std::unique_lock -make_lock(Mutex& mutex, Args&&... args) -{ - return std::unique_lock(mutex, std::forward(args)...); -} - -} // ripple - -#endif diff --git a/src/ripple/beast/asio/io_latency_probe.h b/src/ripple/beast/asio/io_latency_probe.h index 83cff4d5f..2357408a1 100644 --- a/src/ripple/beast/asio/io_latency_probe.h +++ b/src/ripple/beast/asio/io_latency_probe.h @@ -100,7 +100,7 @@ public: template void sample_one (Handler&& handler) { - std::lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); if (m_cancel) throw std::logic_error ("io_latency_probe is canceled"); m_ios.post (sample_op ( @@ -115,7 +115,7 @@ public: template void sample (Handler&& handler) { - std::lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); if (m_cancel) throw std::logic_error ("io_latency_probe is canceled"); m_ios.post (sample_op ( @@ -145,13 +145,13 @@ private: void addref () { - std::lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); ++m_count; } void release () { - std::lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); if (--m_count == 0) m_cond.notify_all (); } @@ -205,8 +205,7 @@ private: m_handler (elapsed); { - std::lock_guard m_mutex) - > lock (m_probe->m_mutex); + std::lock_guard lock (m_probe->m_mutex); if (m_probe->m_cancel) return; } diff --git a/src/ripple/beast/clock/basic_seconds_clock.h b/src/ripple/beast/clock/basic_seconds_clock.h index a1e1a0893..55c77666a 100644 --- a/src/ripple/beast/clock/basic_seconds_clock.h +++ b/src/ripple/beast/clock/basic_seconds_clock.h @@ -51,7 +51,6 @@ class seconds_clock_thread public: using mutex = std::mutex; using cond_var = std::condition_variable; - using lock_guard = std::lock_guard ; using unique_lock = std::unique_lock ; using clock_type = std::chrono::steady_clock; using seconds = std::chrono::seconds; @@ -77,13 +76,13 @@ public: void add (seconds_clock_worker& w) { - lock_guard lock (mutex_); + std::lock_guard lock (mutex_); workers_.push_back (&w); } void remove (seconds_clock_worker& w) { - lock_guard lock (mutex_); + std::lock_guard lock (mutex_); workers_.erase (std::find ( workers_.begin (), workers_.end(), &w)); } @@ -93,7 +92,7 @@ public: if (thread_.joinable()) { { - lock_guard lock (mutex_); + std::lock_guard lock (mutex_); stop_ = true; } cond_.notify_all(); @@ -200,13 +199,13 @@ public: time_point now() { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); return m_now; } void sample() override { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); m_now = Clock::now(); } }; diff --git a/src/ripple/beast/insight/impl/StatsDCollector.cpp b/src/ripple/beast/insight/impl/StatsDCollector.cpp index 599d33bbb..4ef57ebe5 100644 --- a/src/ripple/beast/insight/impl/StatsDCollector.cpp +++ b/src/ripple/beast/insight/impl/StatsDCollector.cpp @@ -281,13 +281,13 @@ public: void add (StatsDMetricBase& metric) { - std::lock_guard _(metricsLock_); + std::lock_guard _(metricsLock_); metrics_.push_back (metric); } void remove (StatsDMetricBase& metric) { - std::lock_guard _(metricsLock_); + std::lock_guard _(metricsLock_); metrics_.erase (metrics_.iterator_to (metric)); } @@ -412,7 +412,7 @@ public: return; } - std::lock_guard _(metricsLock_); + std::lock_guard _(metricsLock_); for (auto& m : metrics_) m.do_process(); diff --git a/src/ripple/beast/utility/src/beast_PropertyStream.cpp b/src/ripple/beast/utility/src/beast_PropertyStream.cpp index 4d49fc9b9..219324485 100644 --- a/src/ripple/beast/utility/src/beast_PropertyStream.cpp +++ b/src/ripple/beast/utility/src/beast_PropertyStream.cpp @@ -180,7 +180,7 @@ PropertyStream::Source::Source (std::string const& name) PropertyStream::Source::~Source () { - std::lock_guard _(lock_); + std::lock_guard _(lock_); if (parent_ != nullptr) parent_->remove (*this); removeAll (); @@ -194,8 +194,8 @@ std::string const& PropertyStream::Source::name () const void PropertyStream::Source::add (Source& source) { std::lock(lock_, source.lock_); - std::lock_guard lk1(lock_, std::adopt_lock); - std::lock_guard lk2(source.lock_, std::adopt_lock); + std::lock_guard lk1(lock_, std::adopt_lock); + std::lock_guard lk2(source.lock_, std::adopt_lock); assert (source.parent_ == nullptr); children_.push_back (source.item_); @@ -205,8 +205,8 @@ void PropertyStream::Source::add (Source& source) void PropertyStream::Source::remove (Source& child) { std::lock(lock_, child.lock_); - std::lock_guard lk1(lock_, std::adopt_lock); - std::lock_guard lk2(child.lock_, std::adopt_lock); + std::lock_guard lk1(lock_, std::adopt_lock); + std::lock_guard lk2(child.lock_, std::adopt_lock); assert (child.parent_ == this); children_.erase ( @@ -217,10 +217,10 @@ void PropertyStream::Source::remove (Source& child) void PropertyStream::Source::removeAll () { - std::lock_guard _(lock_); + std::lock_guard _(lock_); for (auto iter = children_.begin(); iter != children_.end(); ) { - std::lock_guard _cl((*iter)->lock_); + std::lock_guard _cl((*iter)->lock_); remove (*(*iter)); } } @@ -238,7 +238,7 @@ void PropertyStream::Source::write (PropertyStream& stream) Map map (m_name, stream); onWrite (map); - std::lock_guard _(lock_); + std::lock_guard _(lock_); for (auto& child : children_) child.source().write (stream); @@ -326,7 +326,7 @@ PropertyStream::Source* PropertyStream::Source::find_one_deep (std::string const if (found != nullptr) return found; - std::lock_guard _(lock_); + std::lock_guard _(lock_); for (auto& s : children_) { found = s.source().find_one_deep (name); @@ -356,7 +356,7 @@ PropertyStream::Source* PropertyStream::Source::find_path (std::string path) // If no immediate children match, then return nullptr PropertyStream::Source* PropertyStream::Source::find_one (std::string const& name) { - std::lock_guard _(lock_); + std::lock_guard _(lock_); for (auto& s : children_) { if (s.source().m_name == name) diff --git a/src/ripple/consensus/Validations.h b/src/ripple/consensus/Validations.h index 0b5505356..11a86d81b 100644 --- a/src/ripple/consensus/Validations.h +++ b/src/ripple/consensus/Validations.h @@ -286,8 +286,6 @@ class Validations using WrappedValidationType = std::decay_t< std::result_of_t>; - using ScopedLock = std::lock_guard; - // Manages concurrent access to members mutable Mutex mutex_; @@ -328,7 +326,7 @@ class Validations private: // Remove support of a validated ledger void - removeTrie(ScopedLock const&, NodeID const& nodeID, Validation const& val) + removeTrie(std::lock_guard const&, NodeID const& nodeID, Validation const& val) { { auto it = @@ -352,7 +350,7 @@ private: // Check if any pending acquire ledger requests are complete void - checkAcquired(ScopedLock const& lock) + checkAcquired(std::lock_guard const& lock) { for (auto it = acquiring_.begin(); it != acquiring_.end();) { @@ -371,7 +369,7 @@ private: // Update the trie to reflect a new validated ledger void - updateTrie(ScopedLock const&, NodeID const& nodeID, Ledger ledger) + updateTrie(std::lock_guard const&, NodeID const& nodeID, Ledger ledger) { auto ins = lastLedger_.emplace(nodeID, ledger); if (!ins.second) @@ -397,7 +395,7 @@ private: */ void updateTrie( - ScopedLock const& lock, + std::lock_guard const& lock, NodeID const& nodeID, Validation const& val, boost::optional> prior) @@ -448,7 +446,7 @@ private: */ template auto - withTrie(ScopedLock const& lock, F&& f) + withTrie(std::lock_guard const& lock, F&& f) { // Call current to flush any stale validations current(lock, [](auto) {}, [](auto, auto) {}); @@ -474,7 +472,7 @@ private: template void - current(ScopedLock const& lock, Pre&& pre, F&& f) + current(std::lock_guard const& lock, Pre&& pre, F&& f) { NetClock::time_point t = adaptor_.now(); pre(current_.size()); @@ -512,7 +510,7 @@ private: */ template void - byLedger(ScopedLock const&, ID const& ledgerID, Pre&& pre, F&& f) + byLedger(std::lock_guard const&, ID const& ledgerID, Pre&& pre, F&& f) { auto it = byLedger_.find(ledgerID); if (it != byLedger_.end()) @@ -567,7 +565,7 @@ public: bool canValidateSeq(Seq const s) { - ScopedLock lock{mutex_}; + std::lock_guard lock{mutex_}; return localSeqEnforcer_(byLedger_.clock().now(), s, parms_); } @@ -586,7 +584,7 @@ public: return ValStatus::stale; { - ScopedLock lock{mutex_}; + std::lock_guard lock{mutex_}; // Check that validation sequence is greater than any non-expired // validations sequence from that validator @@ -631,7 +629,7 @@ public: void expire() { - ScopedLock lock{mutex_}; + std::lock_guard lock{mutex_}; beast::expire(byLedger_, parms_.validationSET_EXPIRES); } @@ -647,7 +645,7 @@ public: void trustChanged(hash_set const& added, hash_set const& removed) { - ScopedLock lock{mutex_}; + std::lock_guard lock{mutex_}; for (auto& it : current_) { @@ -682,7 +680,7 @@ public: Json::Value getJsonTrie() const { - ScopedLock lock{mutex_}; + std::lock_guard lock{mutex_}; return trie_.getJson(); } @@ -701,7 +699,7 @@ public: boost::optional> getPreferred(Ledger const& curr) { - ScopedLock lock{mutex_}; + std::lock_guard lock{mutex_}; boost::optional> preferred = withTrie(lock, [this](LedgerTrie& trie) { return trie.getPreferred(localSeqEnforcer_.largest()); @@ -825,7 +823,7 @@ public: std::size_t getNodesAfter(Ledger const& ledger, ID const& ledgerID) { - ScopedLock lock{mutex_}; + std::lock_guard lock{mutex_}; // Use trie if ledger is the right one if (ledger.id() == ledgerID) @@ -852,7 +850,7 @@ public: currentTrusted() { std::vector ret; - ScopedLock lock{mutex_}; + std::lock_guard lock{mutex_}; current( lock, [&](std::size_t numValidations) { ret.reserve(numValidations); }, @@ -871,7 +869,7 @@ public: getCurrentNodeIDs() -> hash_set { hash_set ret; - ScopedLock lock{mutex_}; + std::lock_guard lock{mutex_}; current( lock, [&](std::size_t numValidations) { ret.reserve(numValidations); }, @@ -889,7 +887,7 @@ public: numTrustedForLedger(ID const& ledgerID) { std::size_t count = 0; - ScopedLock lock{mutex_}; + std::lock_guard lock{mutex_}; byLedger( lock, ledgerID, @@ -910,7 +908,7 @@ public: getTrustedForLedger(ID const& ledgerID) { std::vector res; - ScopedLock lock{mutex_}; + std::lock_guard lock{mutex_}; byLedger( lock, ledgerID, @@ -933,7 +931,7 @@ public: fees(ID const& ledgerID, std::uint32_t baseFee) { std::vector res; - ScopedLock lock{mutex_}; + std::lock_guard lock{mutex_}; byLedger( lock, ledgerID, @@ -956,7 +954,7 @@ public: void flush() { - ScopedLock lock{mutex_}; + std::lock_guard lock{mutex_}; current_.clear(); } @@ -980,7 +978,7 @@ public: { std::size_t laggards = 0; - current(ScopedLock{mutex_}, + current(std::lock_guard{mutex_}, [](std::size_t) {}, [&](NodeID const&, Validation const& v) { if (adaptor_.now() < diff --git a/src/ripple/core/ClosureCounter.h b/src/ripple/core/ClosureCounter.h index e14364e79..48160e179 100644 --- a/src/ripple/core/ClosureCounter.h +++ b/src/ripple/core/ClosureCounter.h @@ -60,7 +60,7 @@ private: // a lock. This removes a small timing window that occurs if the // waiting thread is handling a spurious wakeup when closureCount_ // drops to zero. - std::lock_guard lock {mutex_}; + std::lock_guard lock {mutex_}; // Update closureCount_. Notify if stopping and closureCount_ == 0. if ((--closureCount_ == 0) && waitForClosures_) @@ -177,7 +177,7 @@ public: { boost::optional> ret; - std::lock_guard lock {mutex_}; + std::lock_guard lock {mutex_}; if (! waitForClosures_) ret.emplace (*this, std::forward (closure)); @@ -198,7 +198,7 @@ public: */ bool joined() const { - std::lock_guard lock {mutex_}; + std::lock_guard lock {mutex_}; return waitForClosures_; } }; diff --git a/src/ripple/core/Coro.ipp b/src/ripple/core/Coro.ipp index e259e2d29..b1b1abe6c 100644 --- a/src/ripple/core/Coro.ipp +++ b/src/ripple/core/Coro.ipp @@ -61,7 +61,7 @@ JobQueue::Coro:: yield() const { { - std::lock_guard lock(jq_.m_mutex); + std::lock_guard lock(jq_.m_mutex); ++jq_.nSuspend_; } (*yield_)(); @@ -73,7 +73,7 @@ JobQueue::Coro:: post() { { - std::lock_guard lk(mutex_run_); + std::lock_guard lk(mutex_run_); running_ = true; } @@ -88,7 +88,7 @@ post() } // The coroutine will not run. Clean up running_. - std::lock_guard lk(mutex_run_); + std::lock_guard lk(mutex_run_); running_ = false; cv_.notify_all(); return false; @@ -100,21 +100,21 @@ JobQueue::Coro:: resume() { { - std::lock_guard lk(mutex_run_); + std::lock_guard lk(mutex_run_); running_ = true; } { - std::lock_guard lock(jq_.m_mutex); + std::lock_guard lock(jq_.m_mutex); --jq_.nSuspend_; } auto saved = detail::getLocalValues().release(); detail::getLocalValues().reset(&lvs_); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); assert (coro_); coro_(); detail::getLocalValues().release(); detail::getLocalValues().reset(saved); - std::lock_guard lk(mutex_run_); + std::lock_guard lk(mutex_run_); running_ = false; cv_.notify_all(); } @@ -142,7 +142,7 @@ expectEarlyExit() // // That said, since we're outside the Coro's stack, we need to // decrement the nSuspend that the Coro's call to yield caused. - std::lock_guard lock(jq_.m_mutex); + std::lock_guard lock(jq_.m_mutex); --jq_.nSuspend_; #ifndef NDEBUG finished_ = true; diff --git a/src/ripple/core/JobQueue.h b/src/ripple/core/JobQueue.h index 9f9fca8b3..7b1dc4924 100644 --- a/src/ripple/core/JobQueue.h +++ b/src/ripple/core/JobQueue.h @@ -245,7 +245,7 @@ private: void onStop() override; // Signals the service stopped if the stopped condition is met. - void checkStopped (std::lock_guard const& lock); + void checkStopped (std::lock_guard const& lock); // Adds a reference counted job to the JobQueue. // @@ -270,7 +270,7 @@ private: // // Invariants: // The calling thread owns the JobLock - void queueJob (Job const& job, std::lock_guard const& lock); + void queueJob (Job const& job, std::lock_guard const& lock); // Returns the next Job we should run now. // diff --git a/src/ripple/core/impl/JobQueue.cpp b/src/ripple/core/impl/JobQueue.cpp index ec1168b30..47767edae 100644 --- a/src/ripple/core/impl/JobQueue.cpp +++ b/src/ripple/core/impl/JobQueue.cpp @@ -40,7 +40,7 @@ JobQueue::JobQueue (beast::insight::Collector::ptr const& collector, job_count = m_collector->make_gauge ("job_count"); { - std::lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); for (auto const& x : JobTypes::instance()) { @@ -65,7 +65,7 @@ JobQueue::~JobQueue () void JobQueue::collect () { - std::lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); job_count = m_jobSet.size (); } @@ -87,7 +87,7 @@ JobQueue::addRefCountedJob (JobType type, std::string const& name, assert (type == jtCLIENT || m_workers.getNumberOfThreads () > 0); { - std::lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); // If this goes off it means that a child didn't follow // the Stoppable API rules. A job may only be added if: @@ -116,7 +116,7 @@ JobQueue::addRefCountedJob (JobType type, std::string const& name, int JobQueue::getJobCount (JobType t) const { - std::lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); JobDataMap::const_iterator c = m_jobData.find (t); @@ -128,7 +128,7 @@ JobQueue::getJobCount (JobType t) const int JobQueue::getJobCountTotal (JobType t) const { - std::lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); JobDataMap::const_iterator c = m_jobData.find (t); @@ -143,7 +143,7 @@ JobQueue::getJobCountGE (JobType t) const // return the number of jobs at this priority level or greater int ret = 0; - std::lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); for (auto const& x : m_jobData) { @@ -225,7 +225,7 @@ JobQueue::getJson (int c) Json::Value priorities = Json::arrayValue; - std::lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); for (auto& x : m_jobData) { @@ -414,7 +414,7 @@ JobQueue::processTask (int instance) { Job job; { - std::lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); getNextJob (job); ++m_processCount; } @@ -436,7 +436,7 @@ JobQueue::processTask (int instance) } { - std::lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); // Job should be destroyed before calling checkStopped // otherwise destructors with side effects can access // parent objects that are already destroyed. @@ -462,7 +462,7 @@ JobQueue::getJobLimit (JobType type) void JobQueue::onChildrenStopped () { - std::lock_guard lock (m_mutex); + std::lock_guard lock (m_mutex); checkStopped (lock); } diff --git a/src/ripple/core/impl/LoadMonitor.cpp b/src/ripple/core/impl/LoadMonitor.cpp index c9ea0223f..fa1733ade 100644 --- a/src/ripple/core/impl/LoadMonitor.cpp +++ b/src/ripple/core/impl/LoadMonitor.cpp @@ -128,7 +128,7 @@ void LoadMonitor::addLoadSample (LoadEvent const& s) */ void LoadMonitor::addSamples (int count, std::chrono::milliseconds latency) { - std::lock_guard sl (mutex_); + std::lock_guard sl (mutex_); update (); mCounts += count; @@ -159,7 +159,7 @@ bool LoadMonitor::isOverTarget (std::chrono::milliseconds avg, bool LoadMonitor::isOver () { - std::lock_guard sl (mutex_); + std::lock_guard sl (mutex_); update (); @@ -174,7 +174,7 @@ LoadMonitor::Stats LoadMonitor::getStats () using namespace std::chrono_literals; Stats stats; - std::lock_guard sl (mutex_); + std::lock_guard sl (mutex_); update (); diff --git a/src/ripple/core/impl/SNTPClock.cpp b/src/ripple/core/impl/SNTPClock.cpp index 169a8bfd9..5941f10a8 100644 --- a/src/ripple/core/impl/SNTPClock.cpp +++ b/src/ripple/core/impl/SNTPClock.cpp @@ -148,7 +148,7 @@ public: } { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); for (auto const& item : servers) servers_.emplace_back( item, sys_seconds::max()); @@ -174,7 +174,7 @@ public: time_point now() const override { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); using namespace std::chrono; auto const when = time_point_cast(clock_type::now()); if ((lastUpdate_ == sys_seconds::max()) || @@ -187,7 +187,7 @@ public: duration offset() const override { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); return offset_; } @@ -237,7 +237,7 @@ public: { JLOG(j_.trace()) << "SNTP: Packet from " << ep_; - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); auto const query = queries_.find (ep_); if (query == queries_.end ()) { @@ -288,7 +288,7 @@ public: void addServer (std::string const& server) { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); servers_.push_back (std::make_pair (server, sys_seconds::max())); } @@ -301,7 +301,7 @@ public: bool doQuery () { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); auto best = servers_.end (); for (auto iter = servers_.begin (), end = best; @@ -366,7 +366,7 @@ public: if (sel != ip::udp::resolver::iterator ()) { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); Query& query = queries_[*sel]; using namespace std::chrono; auto now = time_point_cast(clock_type::now()); diff --git a/src/ripple/core/impl/SociDB.cpp b/src/ripple/core/impl/SociDB.cpp index bac44be41..063e4b469 100644 --- a/src/ripple/core/impl/SociDB.cpp +++ b/src/ripple/core/impl/SociDB.cpp @@ -224,7 +224,7 @@ private: void scheduleCheckpoint () { { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); if (running_) return; running_ = true; @@ -234,7 +234,7 @@ private: if (! jobQueue_.addJob ( jtWAL, "WAL", [this] (Job&) { checkpoint(); })) { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); running_ = false; } } @@ -259,7 +259,7 @@ private: << log << ", written=" << ckpt; } - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); running_ = false; } }; diff --git a/src/ripple/core/impl/Stoppable.cpp b/src/ripple/core/impl/Stoppable.cpp index 5a4755b4c..381687376 100644 --- a/src/ripple/core/impl/Stoppable.cpp +++ b/src/ripple/core/impl/Stoppable.cpp @@ -70,7 +70,7 @@ bool Stoppable::areChildrenStopped () const void Stoppable::stopped () { - std::lock_guard lk{m_mut}; + std::lock_guard lk{m_mut}; m_is_stopping = true; m_cv.notify_all(); } diff --git a/src/ripple/core/impl/TimeKeeper.cpp b/src/ripple/core/impl/TimeKeeper.cpp index eba3be801..e96c2a783 100644 --- a/src/ripple/core/impl/TimeKeeper.cpp +++ b/src/ripple/core/impl/TimeKeeper.cpp @@ -63,14 +63,14 @@ public: time_point now() const override { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); return adjust(clock_->now()); } time_point closeTime() const override { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); return adjust(clock_->now()) + closeOffset_; } @@ -80,7 +80,7 @@ public: { using namespace std::chrono; auto const s = amount.count(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); // Take large offsets, ignore small offsets, // push the close time towards our wall time. if (s > 1) @@ -111,14 +111,14 @@ public: { using namespace std::chrono; using namespace std; - lock_guard lock(mutex_); + lock_guard lock(mutex_); return duration_cast>(clock_->offset()); } std::chrono::duration closeOffset() const override { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); return closeOffset_; } }; diff --git a/src/ripple/core/impl/Workers.cpp b/src/ripple/core/impl/Workers.cpp index 46bc1d38b..ca456de57 100644 --- a/src/ripple/core/impl/Workers.cpp +++ b/src/ripple/core/impl/Workers.cpp @@ -162,7 +162,7 @@ Workers::Worker::Worker (Workers& workers, std::string const& threadName, Workers::Worker::~Worker () { { - std::lock_guard lock {mutex_}; + std::lock_guard lock {mutex_}; ++wakeCount_; shouldExit_ = true; } @@ -173,7 +173,7 @@ Workers::Worker::~Worker () void Workers::Worker::notify () { - std::lock_guard lock {mutex_}; + std::lock_guard lock {mutex_}; ++wakeCount_; wakeup_.notify_one(); } @@ -188,7 +188,7 @@ void Workers::Worker::run () // if (++m_workers.m_activeCount == 1) { - std::lock_guard lk{m_workers.m_mut}; + std::lock_guard lk{m_workers.m_mut}; m_workers.m_allPaused = false; } @@ -242,7 +242,7 @@ void Workers::Worker::run () // if (--m_workers.m_activeCount == 0) { - std::lock_guard lk{m_workers.m_mut}; + std::lock_guard lk{m_workers.m_mut}; m_workers.m_allPaused = true; m_workers.m_cv.notify_all(); } diff --git a/src/ripple/crypto/impl/csprng.cpp b/src/ripple/crypto/impl/csprng.cpp index e284bd415..0f1f310c2 100644 --- a/src/ripple/crypto/impl/csprng.cpp +++ b/src/ripple/crypto/impl/csprng.cpp @@ -36,7 +36,7 @@ csprng_engine::mix ( assert (size != 0); assert (bitsPerByte != 0); - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); RAND_add (data, size, (size * bitsPerByte) / 8.0); } @@ -83,7 +83,7 @@ csprng_engine::operator()() { result_type ret; - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); auto const result = RAND_bytes ( reinterpret_cast(&ret), @@ -98,7 +98,7 @@ csprng_engine::operator()() void csprng_engine::operator()(void *ptr, std::size_t count) { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); auto const result = RAND_bytes ( reinterpret_cast(ptr), diff --git a/src/ripple/ledger/CachedSLEs.h b/src/ripple/ledger/CachedSLEs.h index 69af1d22e..b6815a304 100644 --- a/src/ripple/ledger/CachedSLEs.h +++ b/src/ripple/ledger/CachedSLEs.h @@ -69,8 +69,7 @@ public: Handler const& h) { { - std::lock_guard< - std::mutex> lock(mutex_); + std::lock_guard lock(mutex_); auto iter = map_.find(digest); if (iter != map_.end()) @@ -83,8 +82,7 @@ public: auto sle = h(); if (! sle) return nullptr; - std::lock_guard< - std::mutex> lock(mutex_); + std::lock_guard lock(mutex_); ++miss_; auto const result = map_.emplace( diff --git a/src/ripple/ledger/impl/CachedSLEs.cpp b/src/ripple/ledger/impl/CachedSLEs.cpp index fe317263a..2789d8c68 100644 --- a/src/ripple/ledger/impl/CachedSLEs.cpp +++ b/src/ripple/ledger/impl/CachedSLEs.cpp @@ -30,8 +30,7 @@ CachedSLEs::expire() { auto const expireTime = map_.clock().now() - timeToLive_; - std::lock_guard< - std::mutex> lock(mutex_); + std::lock_guard lock(mutex_); for (auto iter = map_.chronological.begin(); iter != map_.chronological.end(); ++iter) { @@ -50,8 +49,7 @@ CachedSLEs::expire() double CachedSLEs::rate() const { - std::lock_guard< - std::mutex> lock(mutex_); + std::lock_guard lock(mutex_); auto const tot = hit_ + miss_; if (tot == 0) return 0; diff --git a/src/ripple/ledger/impl/CachedView.cpp b/src/ripple/ledger/impl/CachedView.cpp index 14bfe9431..3d5c72137 100644 --- a/src/ripple/ledger/impl/CachedView.cpp +++ b/src/ripple/ledger/impl/CachedView.cpp @@ -34,7 +34,7 @@ std::shared_ptr CachedViewImpl::read(Keylet const& k) const { { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); auto const iter = map_.find(k.key); if (iter != map_.end()) { @@ -47,7 +47,7 @@ CachedViewImpl::read(Keylet const& k) const if (!digest) return nullptr; auto sle = cache_.fetch(*digest, [&]() { return base_.read(k); }); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); auto const er = map_.emplace(k.key, sle); auto const& iter = er.first; bool const inserted = er.second; diff --git a/src/ripple/net/InfoSub.h b/src/ripple/net/InfoSub.h index 60d85d53e..6d97ffc39 100644 --- a/src/ripple/net/InfoSub.h +++ b/src/ripple/net/InfoSub.h @@ -147,9 +147,7 @@ public: std::shared_ptr const& getPathRequest (); protected: - using LockType = std::mutex; - using ScopedLockType = std::lock_guard ; - LockType mLock; + std::mutex mLock; private: Consumer m_consumer; diff --git a/src/ripple/net/impl/InfoSub.cpp b/src/ripple/net/impl/InfoSub.cpp index bc887ad3b..bfe4fd642 100644 --- a/src/ripple/net/impl/InfoSub.cpp +++ b/src/ripple/net/impl/InfoSub.cpp @@ -92,7 +92,7 @@ void InfoSub::onSendEmpty () void InfoSub::insertSubAccountInfo (AccountID const& account, bool rt) { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); if (rt) realTimeSubscriptions_.insert (account); @@ -102,7 +102,7 @@ void InfoSub::insertSubAccountInfo (AccountID const& account, bool rt) void InfoSub::deleteSubAccountInfo (AccountID const& account, bool rt) { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); if (rt) realTimeSubscriptions_.erase (account); diff --git a/src/ripple/net/impl/RPCSub.cpp b/src/ripple/net/impl/RPCSub.cpp index 57a2361d4..33ba9c4a2 100644 --- a/src/ripple/net/impl/RPCSub.cpp +++ b/src/ripple/net/impl/RPCSub.cpp @@ -72,7 +72,7 @@ public: void send (Json::Value const& jvObj, bool broadcast) override { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); if (mDeque.size () >= eventQueueMax) { @@ -101,14 +101,14 @@ public: void setUsername (std::string const& strUsername) override { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); mUsername = strUsername; } void setPassword (std::string const& strPassword) override { - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); mPassword = strPassword; } @@ -124,7 +124,7 @@ private: { { // Obtain the lock to manipulate the queue and change sending. - ScopedLockType sl (mLock); + std::lock_guard sl (mLock); if (mDeque.empty ()) { diff --git a/src/ripple/nodestore/backend/MemoryFactory.cpp b/src/ripple/nodestore/backend/MemoryFactory.cpp index b88b7b921..0b255b78b 100644 --- a/src/ripple/nodestore/backend/MemoryFactory.cpp +++ b/src/ripple/nodestore/backend/MemoryFactory.cpp @@ -61,7 +61,7 @@ public: MemoryDB& open (std::string const& path) { - std::lock_guard _(mutex_); + std::lock_guard _(mutex_); auto const result = map_.emplace (std::piecewise_construct, std::make_tuple(path), std::make_tuple()); MemoryDB& db = result.first->second; @@ -126,7 +126,7 @@ public: assert(db_); uint256 const hash (uint256::fromVoid (key)); - std::lock_guard _(db_->mutex); + std::lock_guard _(db_->mutex); Map::iterator iter = db_->table.find (hash); if (iter == db_->table.end()) @@ -155,7 +155,7 @@ public: store (std::shared_ptr const& object) override { assert(db_); - std::lock_guard _(db_->mutex); + std::lock_guard _(db_->mutex); db_->table.emplace (object->getHash(), object); } diff --git a/src/ripple/nodestore/impl/BatchWriter.cpp b/src/ripple/nodestore/impl/BatchWriter.cpp index e05b3ea64..a81dcf736 100644 --- a/src/ripple/nodestore/impl/BatchWriter.cpp +++ b/src/ripple/nodestore/impl/BatchWriter.cpp @@ -59,7 +59,7 @@ BatchWriter::store (std::shared_ptr const& object) int BatchWriter::getWriteLoad () { - std::lock_guard sl (mWriteMutex); + std::lock_guard sl (mWriteMutex); return std::max (mWriteLoad, static_cast (mWriteSet.size ())); } @@ -80,7 +80,7 @@ BatchWriter::writeBatch () set.reserve (batchWritePreallocationSize); { - std::lock_guard sl (mWriteMutex); + std::lock_guard sl (mWriteMutex); mWriteSet.swap (set); assert (mWriteSet.empty ()); diff --git a/src/ripple/nodestore/impl/Database.cpp b/src/ripple/nodestore/impl/Database.cpp index 5cf0ddf38..f6a3c3785 100644 --- a/src/ripple/nodestore/impl/Database.cpp +++ b/src/ripple/nodestore/impl/Database.cpp @@ -90,7 +90,7 @@ void Database::stopThreads() { { - std::lock_guard lock(readLock_); + std::lock_guard lock(readLock_); if (readShut_) // Only stop threads once. return; @@ -109,7 +109,7 @@ Database::asyncFetch(uint256 const& hash, std::uint32_t seq, std::shared_ptr> const& nCache) { // Post a read - std::lock_guard lock(readLock_); + std::lock_guard lock(readLock_); if (read_.emplace(hash, std::make_tuple(seq, pCache, nCache)).second) readCondVar_.notify_one(); } diff --git a/src/ripple/nodestore/impl/DatabaseRotatingImp.h b/src/ripple/nodestore/impl/DatabaseRotatingImp.h index b3ef47d2e..e925de5d8 100644 --- a/src/ripple/nodestore/impl/DatabaseRotatingImp.h +++ b/src/ripple/nodestore/impl/DatabaseRotatingImp.h @@ -51,7 +51,7 @@ public: std::unique_ptr const& getWritableBackend() const override { - std::lock_guard lock (rotateMutex_); + std::lock_guard lock (rotateMutex_); return writableBackend_; } @@ -137,7 +137,7 @@ private: Backends getBackends() const { - std::lock_guard lock (rotateMutex_); + std::lock_guard lock (rotateMutex_); return Backends {writableBackend_, archiveBackend_}; } diff --git a/src/ripple/nodestore/impl/DatabaseShardImp.cpp b/src/ripple/nodestore/impl/DatabaseShardImp.cpp index 291cc7399..2c872a05c 100644 --- a/src/ripple/nodestore/impl/DatabaseShardImp.cpp +++ b/src/ripple/nodestore/impl/DatabaseShardImp.cpp @@ -59,7 +59,7 @@ DatabaseShardImp::~DatabaseShardImp() stopThreads(); // Close backend databases before destroying the context - std::lock_guard lock(m_); + std::lock_guard lock(m_); complete_.clear(); if (incomplete_) incomplete_.reset(); @@ -73,7 +73,7 @@ DatabaseShardImp::init() using namespace boost::filesystem; using namespace boost::beast::detail; - std::lock_guard lock(m_); + std::lock_guard lock(m_); if (init_) { JLOG(j_.error()) << @@ -269,7 +269,7 @@ DatabaseShardImp::init() boost::optional DatabaseShardImp::prepareLedger(std::uint32_t validLedgerSeq) { - std::lock_guard lock(m_); + std::lock_guard lock(m_); assert(init_); if (incomplete_) return incomplete_->prepare(); @@ -323,7 +323,7 @@ DatabaseShardImp::prepareLedger(std::uint32_t validLedgerSeq) bool DatabaseShardImp::prepareShard(std::uint32_t shardIndex) { - std::lock_guard lock(m_); + std::lock_guard lock(m_); assert(init_); if (!canAdd_) { @@ -407,7 +407,7 @@ DatabaseShardImp::prepareShard(std::uint32_t shardIndex) void DatabaseShardImp::removePreShard(std::uint32_t shardIndex) { - std::lock_guard lock(m_); + std::lock_guard lock(m_); assert(init_); preShards_.erase(shardIndex); } @@ -417,7 +417,7 @@ DatabaseShardImp::getPreShards() { RangeSet rs; { - std::lock_guard lock(m_); + std::lock_guard lock(m_); assert(init_); if (preShards_.empty()) return {}; @@ -598,7 +598,7 @@ DatabaseShardImp::setStored(std::shared_ptr const& ledger) return; } auto const shardIndex {seqToShardIndex(ledger->info().seq)}; - std::lock_guard lock(m_); + std::lock_guard lock(m_); assert(init_); if (!incomplete_ || shardIndex != incomplete_->index()) { @@ -637,7 +637,7 @@ bool DatabaseShardImp::contains(std::uint32_t seq) { auto const shardIndex {seqToShardIndex(seq)}; - std::lock_guard lock(m_); + std::lock_guard lock(m_); assert(init_); if (complete_.find(shardIndex) != complete_.end()) return true; @@ -649,7 +649,7 @@ DatabaseShardImp::contains(std::uint32_t seq) std::string DatabaseShardImp::getCompleteShards() { - std::lock_guard lock(m_); + std::lock_guard lock(m_); assert(init_); return status_; } @@ -658,7 +658,7 @@ void DatabaseShardImp::validate() { { - std::lock_guard lock(m_); + std::lock_guard lock(m_); assert(init_); if (complete_.empty() && !incomplete_) { @@ -893,7 +893,7 @@ DatabaseShardImp::getWriteLoad() const { std::int32_t wl {0}; { - std::lock_guard lock(m_); + std::lock_guard lock(m_); assert(init_); for (auto const& c : complete_) wl += c.second->getBackend()->getWriteLoad(); @@ -913,7 +913,7 @@ DatabaseShardImp::store(NodeObjectType type, std::shared_ptr nObj; auto const shardIndex {seqToShardIndex(seq)}; { - std::lock_guard lock(m_); + std::lock_guard lock(m_); assert(init_); if (!incomplete_ || shardIndex != incomplete_->index()) { @@ -961,7 +961,7 @@ bool DatabaseShardImp::copyLedger(std::shared_ptr const& ledger) { auto const shardIndex {seqToShardIndex(ledger->info().seq)}; - std::lock_guard lock(m_); + std::lock_guard lock(m_); assert(init_); if (!incomplete_ || shardIndex != incomplete_->index()) { @@ -1001,7 +1001,7 @@ DatabaseShardImp::getDesiredAsyncReadCount(std::uint32_t seq) { auto const shardIndex {seqToShardIndex(seq)}; { - std::lock_guard lock(m_); + std::lock_guard lock(m_); assert(init_); auto it = complete_.find(shardIndex); if (it != complete_.end()) @@ -1017,7 +1017,7 @@ DatabaseShardImp::getCacheHitRate() { float sz, f {0}; { - std::lock_guard lock(m_); + std::lock_guard lock(m_); assert(init_); sz = complete_.size(); for (auto const& c : complete_) @@ -1034,7 +1034,7 @@ DatabaseShardImp::getCacheHitRate() void DatabaseShardImp::tune(int size, std::chrono::seconds age) { - std::lock_guard lock(m_); + std::lock_guard lock(m_); assert(init_); cacheSz_ = size; cacheAge_ = age; @@ -1058,7 +1058,7 @@ DatabaseShardImp::tune(int size, std::chrono::seconds age) void DatabaseShardImp::sweep() { - std::lock_guard lock(m_); + std::lock_guard lock(m_); assert(init_); int const sz {calcTargetCacheSz(lock)}; for (auto const& c : complete_) @@ -1220,7 +1220,7 @@ std::pair, std::shared_ptr> DatabaseShardImp::selectCache(std::uint32_t seq) { auto const shardIndex {seqToShardIndex(seq)}; - std::lock_guard lock(m_); + std::lock_guard lock(m_); assert(init_); { auto it = complete_.find(shardIndex); diff --git a/src/ripple/nodestore/impl/ManagerImp.cpp b/src/ripple/nodestore/impl/ManagerImp.cpp index dc38a0c07..50624ce7d 100644 --- a/src/ripple/nodestore/impl/ManagerImp.cpp +++ b/src/ripple/nodestore/impl/ManagerImp.cpp @@ -81,14 +81,14 @@ ManagerImp::make_Database ( void ManagerImp::insert (Factory& factory) { - std::lock_guard _(mutex_); + std::lock_guard _(mutex_); list_.push_back(&factory); } void ManagerImp::erase (Factory& factory) { - std::lock_guard _(mutex_); + std::lock_guard _(mutex_); auto const iter = std::find_if(list_.begin(), list_.end(), [&factory](Factory* other) { return other == &factory; }); assert(iter != list_.end()); @@ -98,7 +98,7 @@ ManagerImp::erase (Factory& factory) Factory* ManagerImp::find (std::string const& name) { - std::lock_guard _(mutex_); + std::lock_guard _(mutex_); auto const iter = std::find_if(list_.begin(), list_.end(), [&name](Factory* other) { diff --git a/src/ripple/overlay/PeerReservationTable.h b/src/ripple/overlay/PeerReservationTable.h index 8dba2d132..006ede698 100644 --- a/src/ripple/overlay/PeerReservationTable.h +++ b/src/ripple/overlay/PeerReservationTable.h @@ -88,7 +88,7 @@ public: bool contains(PublicKey const& nodeId) { - std::lock_guard lock(this->mutex_); + std::lock_guard lock(this->mutex_); return table_.find({nodeId}) != table_.end(); } diff --git a/src/ripple/overlay/impl/Cluster.cpp b/src/ripple/overlay/impl/Cluster.cpp index 3f5a11224..ca7020d65 100644 --- a/src/ripple/overlay/impl/Cluster.cpp +++ b/src/ripple/overlay/impl/Cluster.cpp @@ -39,7 +39,7 @@ Cluster::Cluster (beast::Journal j) boost::optional Cluster::member (PublicKey const& identity) const { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); auto iter = nodes_.find (identity); if (iter == nodes_.end ()) @@ -50,7 +50,7 @@ Cluster::member (PublicKey const& identity) const std::size_t Cluster::size() const { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); return nodes_.size(); } @@ -62,7 +62,7 @@ Cluster::update ( std::uint32_t loadFee, NetClock::time_point reportTime) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); // We can't use auto here yet due to the libstdc++ issue // described at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68190 @@ -88,7 +88,7 @@ void Cluster::for_each ( std::function func) const { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); for (auto const& ni : nodes_) func (ni); } diff --git a/src/ripple/overlay/impl/OverlayImpl.cpp b/src/ripple/overlay/impl/OverlayImpl.cpp index 20a130250..a9c4d79d3 100644 --- a/src/ripple/overlay/impl/OverlayImpl.cpp +++ b/src/ripple/overlay/impl/OverlayImpl.cpp @@ -306,7 +306,7 @@ OverlayImpl::onHandoff (std::unique_ptr && ssl_bundle, // As we are not on the strand, run() must be called // while holding the lock, otherwise new I/O can be // queued after a call to stop(). - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); { auto const result = m_peers.emplace (peer->slot(), peer); @@ -408,7 +408,7 @@ OverlayImpl::connect (beast::IP::Endpoint const& remote_endpoint) usage, setup_.context, next_id_++, slot, app_.journal("Peer"), *this); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); list_.emplace(p.get(), p); p->run(); } @@ -419,7 +419,7 @@ OverlayImpl::connect (beast::IP::Endpoint const& remote_endpoint) void OverlayImpl::add_active (std::shared_ptr const& peer) { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); { auto const result = @@ -455,7 +455,7 @@ OverlayImpl::add_active (std::shared_ptr const& peer) void OverlayImpl::remove (PeerFinder::Slot::ptr const& slot) { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); auto const iter = m_peers.find (slot); assert(iter != m_peers.end ()); m_peers.erase (iter); @@ -574,7 +574,7 @@ void OverlayImpl::onStart () { auto const timer = std::make_shared(*this); - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); list_.emplace(timer.get(), timer); timer_ = timer; timer->run(); @@ -589,7 +589,7 @@ OverlayImpl::onStop () void OverlayImpl::onChildrenStopped () { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); checkStopped (); } @@ -629,7 +629,7 @@ OverlayImpl::activate (std::shared_ptr const& peer) { // Now track this peer { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); auto const result (ids_.emplace ( std::piecewise_construct, std::make_tuple (peer->id()), @@ -652,7 +652,7 @@ OverlayImpl::activate (std::shared_ptr const& peer) void OverlayImpl::onPeerDeactivate (Peer::id_t id) { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); ids_.erase(id); } @@ -765,7 +765,7 @@ OverlayImpl::crawlShards(bool pubKey, std::uint32_t hops) if (csIDs_.empty()) { { - std::lock_guard lock {mutex_}; + std::lock_guard lock {mutex_}; for (auto& id : ids_) csIDs_.emplace(id.first); } @@ -831,7 +831,7 @@ OverlayImpl::lastLink(std::uint32_t id) // Notify threads when every peer has received a last link. // This doesn't account for every node that might reply but // it is adequate. - std::lock_guard l {csMutex_}; + std::lock_guard l {csMutex_}; if (csIDs_.erase(id) && csIDs_.empty()) csCV_.notify_all(); } @@ -873,7 +873,7 @@ OverlayImpl::selectPeers (PeerSet& set, std::size_t limit, std::size_t OverlayImpl::size() { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); return ids_.size (); } @@ -1077,7 +1077,7 @@ OverlayImpl::check () std::shared_ptr OverlayImpl::findPeerByShortID (Peer::id_t const& id) { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); auto const iter = ids_.find (id); if (iter != ids_.end ()) return iter->second.lock(); @@ -1089,7 +1089,7 @@ OverlayImpl::findPeerByShortID (Peer::id_t const& id) std::shared_ptr OverlayImpl::findPeerByPublicKey (PublicKey const& pubKey) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); for (auto const& e : ids_) { if (auto peer = e.second.lock()) @@ -1170,7 +1170,7 @@ OverlayImpl::relay (protocol::TMValidation& m, uint256 const& uid) void OverlayImpl::remove (Child& child) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); list_.erase(&child); if (list_.empty()) checkStopped(); @@ -1189,7 +1189,7 @@ OverlayImpl::stop() // won't be called until vector<> children leaves scope. std::vector> children; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!work_) return; work_ = boost::none; @@ -1224,7 +1224,7 @@ OverlayImpl::sendEndpoints() { std::shared_ptr peer; { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); auto const iter = m_peers.find (e.first); if (iter != m_peers.end()) peer = iter->second.lock(); diff --git a/src/ripple/overlay/impl/OverlayImpl.h b/src/ripple/overlay/impl/OverlayImpl.h index d5c9228e5..64fa2a225 100644 --- a/src/ripple/overlay/impl/OverlayImpl.h +++ b/src/ripple/overlay/impl/OverlayImpl.h @@ -243,7 +243,7 @@ public: { std::vector> wp; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); // Iterate over a copy of the peer list because peer // destruction can invalidate iterators. diff --git a/src/ripple/overlay/impl/PeerImp.cpp b/src/ripple/overlay/impl/PeerImp.cpp index 9ff142d51..9f43bb9ed 100644 --- a/src/ripple/overlay/impl/PeerImp.cpp +++ b/src/ripple/overlay/impl/PeerImp.cpp @@ -129,7 +129,7 @@ PeerImp::run() { // Operations on closedLedgerHash_ and previousLedgerHash_ must be // guarded by recentLock_. - std::lock_guard sl(recentLock_); + std::lock_guard sl(recentLock_); closedLedgerHash_ = hello_.ledgerclosed(); @@ -304,7 +304,7 @@ PeerImp::json() } { - std::lock_guard sl (recentLock_); + std::lock_guard sl (recentLock_); if (latency_) ret[jss::latency] = static_cast (latency_->count()); } @@ -337,7 +337,7 @@ PeerImp::json() uint256 closedLedgerHash; protocol::TMStatusChange last_status; { - std::lock_guard sl(recentLock_); + std::lock_guard sl(recentLock_); closedLedgerHash = closedLedgerHash_; last_status = last_status_; } @@ -384,7 +384,7 @@ bool PeerImp::hasLedger (uint256 const& hash, std::uint32_t seq) const { { - std::lock_guard sl(recentLock_); + std::lock_guard sl(recentLock_); if ((seq != 0) && (seq >= minLedger_) && (seq <= maxLedger_) && (sanity_.load() == Sanity::sane)) return true; @@ -401,7 +401,7 @@ void PeerImp::ledgerRange (std::uint32_t& minSeq, std::uint32_t& maxSeq) const { - std::lock_guard sl(recentLock_); + std::lock_guard sl(recentLock_); minSeq = minLedger_; maxSeq = maxLedger_; @@ -410,7 +410,7 @@ PeerImp::ledgerRange (std::uint32_t& minSeq, bool PeerImp::hasShard (std::uint32_t shardIndex) const { - std::lock_guard l {shardInfoMutex_}; + std::lock_guard l {shardInfoMutex_}; auto const it {shardInfo_.find(publicKey_)}; if (it != shardInfo_.end()) return boost::icl::contains(it->second.shardIndexes, shardIndex); @@ -420,7 +420,7 @@ PeerImp::hasShard (std::uint32_t shardIndex) const bool PeerImp::hasTxSet (uint256 const& hash) const { - std::lock_guard sl(recentLock_); + std::lock_guard sl(recentLock_); return std::find (recentTxSets_.begin(), recentTxSets_.end(), hash) != recentTxSets_.end(); } @@ -430,7 +430,7 @@ PeerImp::cycleStatus () { // Operations on closedLedgerHash_ and previousLedgerHash_ must be // guarded by recentLock_. - std::lock_guard sl(recentLock_); + std::lock_guard sl(recentLock_); previousLedgerHash_ = closedLedgerHash_; closedLedgerHash_.zero (); } @@ -444,7 +444,7 @@ PeerImp::supportsVersion (int version) bool PeerImp::hasRange (std::uint32_t uMin, std::uint32_t uMax) { - std::lock_guard sl(recentLock_); + std::lock_guard sl(recentLock_); return (sanity_ != Sanity::insane) && (uMin >= minLedger_) && (uMax <= maxLedger_); @@ -511,7 +511,7 @@ PeerImp::fail(std::string const& name, error_code ec) boost::optional> PeerImp::getShardIndexes() const { - std::lock_guard l {shardInfoMutex_}; + std::lock_guard l {shardInfoMutex_}; auto it{shardInfo_.find(publicKey_)}; if (it != shardInfo_.end()) return it->second.shardIndexes; @@ -521,7 +521,7 @@ PeerImp::getShardIndexes() const boost::optional> PeerImp::getPeerShardInfo() const { - std::lock_guard l {shardInfoMutex_}; + std::lock_guard l {shardInfoMutex_}; if (!shardInfo_.empty()) return shardInfo_; return boost::none; @@ -611,7 +611,7 @@ PeerImp::onTimer (error_code const& ec) // Operations on lastPingSeq_, lastPingTime_, no_ping_, and latency_ // must be guarded by recentLock_. { - std::lock_guard sl(recentLock_); + std::lock_guard sl(recentLock_); if (no_ping_++ >= Tuning::noPing) { failedNoPing = true; @@ -714,7 +714,7 @@ void PeerImp::doAccept() { // Operations on closedLedgerHash_ and previousLedgerHash_ must be // guarded by recentLock_. - std::lock_guard sl(recentLock_); + std::lock_guard sl(recentLock_); closedLedgerHash_ = hello_.ledgerclosed(); @@ -988,7 +988,7 @@ PeerImp::onMessage (std::shared_ptr const& m) { // Operations on lastPingSeq_, lastPingTime_, no_ping_, and latency_ // must be guarded by recentLock_. - std::lock_guard sl(recentLock_); + std::lock_guard sl(recentLock_); if (m->has_seq() && m->seq() == lastPingSeq_) { @@ -1324,7 +1324,7 @@ PeerImp::onMessage(std::shared_ptr const& m) publicKey = publicKey_; { - std::lock_guard l {shardInfoMutex_}; + std::lock_guard l {shardInfoMutex_}; auto it {shardInfo_.find(publicKey)}; if (it != shardInfo_.end()) { @@ -1709,7 +1709,7 @@ PeerImp::onMessage (std::shared_ptr const& m) m->set_networktime (app_.timeKeeper().now().time_since_epoch().count()); { - std::lock_guard sl(recentLock_); + std::lock_guard sl(recentLock_); if (!last_status_.has_newstatus () || m->has_newstatus ()) last_status_ = *m; else @@ -1727,7 +1727,7 @@ PeerImp::onMessage (std::shared_ptr const& m) { // Operations on closedLedgerHash_ and previousLedgerHash_ must be // guarded by recentLock_. - std::lock_guard sl(recentLock_); + std::lock_guard sl(recentLock_); if (!closedLedgerHash_.isZero ()) { outOfSync = true; @@ -1750,7 +1750,7 @@ PeerImp::onMessage (std::shared_ptr const& m) { // Operations on closedLedgerHash_ and previousLedgerHash_ must be // guarded by recentLock_. - std::lock_guard sl(recentLock_); + std::lock_guard sl(recentLock_); if (peerChangedLedgers) { closedLedgerHash_ = m->ledgerhash(); @@ -1786,7 +1786,7 @@ PeerImp::onMessage (std::shared_ptr const& m) if (m->has_firstseq () && m->has_lastseq()) { - std::lock_guard sl (recentLock_); + std::lock_guard sl (recentLock_); minLedger_ = m->firstseq (); maxLedger_ = m->lastseq (); @@ -1856,7 +1856,7 @@ PeerImp::onMessage (std::shared_ptr const& m) { uint256 closedLedgerHash {}; { - std::lock_guard sl(recentLock_); + std::lock_guard sl(recentLock_); closedLedgerHash = closedLedgerHash_; } j[jss::ledger_hash] = to_string (closedLedgerHash); @@ -1886,7 +1886,7 @@ PeerImp::checkSanity (std::uint32_t validationSeq) { // Extract the seqeuence number of the highest // ledger this peer has - std::lock_guard sl (recentLock_); + std::lock_guard sl (recentLock_); serverSeq = maxLedger_; } @@ -1912,7 +1912,7 @@ PeerImp::checkSanity (std::uint32_t seq1, std::uint32_t seq2) if ((diff > Tuning::insaneLedgerLimit) && (sanity_.load() != Sanity::insane)) { // The peer's ledger sequence is way off the validation's - std::lock_guard sl(recentLock_); + std::lock_guard sl(recentLock_); sanity_ = Sanity::insane; insaneTime_ = clock_type::now(); @@ -1928,7 +1928,7 @@ void PeerImp::check () clock_type::time_point insaneTime; { - std::lock_guard sl(recentLock_); + std::lock_guard sl(recentLock_); insaneTime = insaneTime_; } @@ -1968,7 +1968,7 @@ PeerImp::onMessage (std::shared_ptr const& m) if (m->status () == protocol::tsHAVE) { - std::lock_guard sl(recentLock_); + std::lock_guard sl(recentLock_); if (std::find (recentTxSets_.begin (), recentTxSets_.end (), hash) != recentTxSets_.end ()) @@ -2830,7 +2830,7 @@ PeerImp::getScore (bool haveItem) const boost::optional latency; { - std::lock_guard sl (recentLock_); + std::lock_guard sl (recentLock_); latency = latency_; } @@ -2845,7 +2845,7 @@ PeerImp::getScore (bool haveItem) const bool PeerImp::isHighLatency() const { - std::lock_guard sl (recentLock_); + std::lock_guard sl (recentLock_); return latency_ >= Tuning::peerHighLatency; } diff --git a/src/ripple/overlay/impl/PeerReservationTable.cpp b/src/ripple/overlay/impl/PeerReservationTable.cpp index 407505161..4f6dd2d01 100644 --- a/src/ripple/overlay/impl/PeerReservationTable.cpp +++ b/src/ripple/overlay/impl/PeerReservationTable.cpp @@ -52,7 +52,7 @@ PeerReservationTable::list() const -> std::vector { std::vector list; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); list.reserve(table_.size()); std::copy(table_.begin(), table_.end(), std::back_inserter(list)); } @@ -69,7 +69,7 @@ PeerReservationTable::list() const -> std::vector bool PeerReservationTable::load(DatabaseCon& connection) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); connection_ = &connection; auto db = connection_->checkoutDb(); @@ -111,7 +111,7 @@ PeerReservationTable::insert_or_assign( { boost::optional previous; - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); auto hint = table_.find(reservation); if (hint != table_.end()) { @@ -150,7 +150,7 @@ PeerReservationTable::erase(PublicKey const& nodeId) { boost::optional previous; - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); auto const it = table_.find({nodeId}); if (it != table_.end()) diff --git a/src/ripple/peerfinder/impl/Checker.h b/src/ripple/peerfinder/impl/Checker.h index 982979e16..435e7c7cd 100644 --- a/src/ripple/peerfinder/impl/Checker.h +++ b/src/ripple/peerfinder/impl/Checker.h @@ -182,7 +182,7 @@ template void Checker::stop() { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); if (! stop_) { stop_ = true; @@ -209,7 +209,7 @@ Checker::async_connect ( auto const op = std::make_shared> ( *this, io_service_, std::forward(handler)); { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); list_.push_back (*op); } op->socket_.async_connect (beast::IPAddressConversion::to_asio_endpoint ( @@ -221,7 +221,7 @@ template void Checker::remove (basic_async_op& op) { - std::lock_guard lock (mutex_); + std::lock_guard lock (mutex_); list_.erase (list_.iterator_to (op)); if (list_.size() == 0) cond_.notify_all(); diff --git a/src/ripple/peerfinder/impl/Logic.h b/src/ripple/peerfinder/impl/Logic.h index 86634999f..d1b70f0f7 100644 --- a/src/ripple/peerfinder/impl/Logic.h +++ b/src/ripple/peerfinder/impl/Logic.h @@ -127,7 +127,7 @@ public: // void load () { - std::lock_guard _(lock_); + std::lock_guard _(lock_); bootcache_.load (); } @@ -139,7 +139,7 @@ public: */ void stop () { - std::lock_guard _(lock_); + std::lock_guard _(lock_); stopping_ = true; if (fetchSource_ != nullptr) fetchSource_->cancel (); @@ -154,7 +154,7 @@ public: void config (Config const& c) { - std::lock_guard _(lock_); + std::lock_guard _(lock_); config_ = c; counts_.onConfig (config_); } @@ -162,7 +162,7 @@ public: Config config() { - std::lock_guard _(lock_); + std::lock_guard _(lock_); return config_; } @@ -179,7 +179,7 @@ public: addFixedPeer (std::string const& name, std::vector const& addresses) { - std::lock_guard _(lock_); + std::lock_guard _(lock_); if (addresses.empty ()) { @@ -220,7 +220,7 @@ public: if (ec == boost::asio::error::operation_aborted) return; - std::lock_guard _(lock_); + std::lock_guard _(lock_); auto const iter (slots_.find (remoteAddress)); if (iter == slots_.end()) { @@ -261,7 +261,7 @@ public: "Logic accept" << remote_endpoint << " on local " << local_endpoint; - std::lock_guard _(lock_); + std::lock_guard _(lock_); // Check for duplicate connection if (is_public (remote_endpoint)) @@ -302,7 +302,7 @@ public: JLOG(m_journal.debug()) << beast::leftw (18) << "Logic connect " << remote_endpoint; - std::lock_guard _(lock_); + std::lock_guard _(lock_); // Check for duplicate connection if (slots_.find (remote_endpoint) != @@ -342,7 +342,7 @@ public: "Logic connected" << slot->remote_endpoint () << " on local " << local_endpoint; - std::lock_guard _(lock_); + std::lock_guard _(lock_); // The object must exist in our table assert (slots_.find (slot->remote_endpoint ()) != @@ -378,7 +378,7 @@ public: "Logic handshake " << slot->remote_endpoint () << " with " << (reserved ? "reserved " : "") << "key " << key; - std::lock_guard _(lock_); + std::lock_guard _(lock_); // The object must exist in our table assert (slots_.find (slot->remote_endpoint ()) != @@ -445,7 +445,7 @@ public: std::vector redirect (SlotImp::ptr const& slot) { - std::lock_guard _(lock_); + std::lock_guard _(lock_); RedirectHandouts h (slot); livecache_.hops.shuffle(); handout (&h, (&h)+1, @@ -465,7 +465,7 @@ public: { std::vector const none; - std::lock_guard _(lock_); + std::lock_guard _(lock_); // Count how many more outbound attempts to make // @@ -578,7 +578,7 @@ public: { std::vector>> result; - std::lock_guard _(lock_); + std::lock_guard _(lock_); clock_type::time_point const now = m_clock.now(); if (m_whenBroadcast <= now) @@ -663,7 +663,7 @@ public: void once_per_second() { - std::lock_guard _(lock_); + std::lock_guard _(lock_); // Expire the Livecache livecache_.expire (); @@ -759,7 +759,7 @@ public: " contained " << list.size () << ((list.size() > 1) ? " entries" : " entry"); - std::lock_guard _(lock_); + std::lock_guard _(lock_); // The object must exist in our table assert (slots_.find (slot->remote_endpoint ()) != @@ -860,7 +860,7 @@ public: void on_closed (SlotImp::ptr const& slot) { - std::lock_guard _(lock_); + std::lock_guard _(lock_); remove (slot); @@ -909,7 +909,7 @@ public: void on_failure (SlotImp::ptr const& slot) { - std::lock_guard _(lock_); + std::lock_guard _(lock_); bootcache_.on_failure (slot->remote_endpoint ()); } @@ -1000,7 +1000,7 @@ public: int addBootcacheAddresses (IPAddresses const& list) { int count (0); - std::lock_guard _(lock_); + std::lock_guard _(lock_); for (auto addr : list) { if (bootcache_.insertStatic (addr)) @@ -1017,7 +1017,7 @@ public: { { - std::lock_guard _(lock_); + std::lock_guard _(lock_); if (stopping_) return; fetchSource_ = source; @@ -1029,7 +1029,7 @@ public: source->fetch (results, m_journal); { - std::lock_guard _(lock_); + std::lock_guard _(lock_); if (stopping_) return; fetchSource_ = nullptr; @@ -1098,7 +1098,7 @@ public: void onWrite (beast::PropertyStream::Map& map) { - std::lock_guard _(lock_); + std::lock_guard _(lock_); // VFALCO NOTE These ugly casts are needed because // of how std::size_t is declared on some linuxes @@ -1167,7 +1167,7 @@ void Logic::onRedirects (FwdIter first, FwdIter last, boost::asio::ip::tcp::endpoint const& remote_address) { - std::lock_guard _(lock_); + std::lock_guard _(lock_); std::size_t n = 0; for(;first != last && n < Tuning::maxRedirects; ++first, ++n) bootcache_.insert( diff --git a/src/ripple/protocol/impl/AccountID.cpp b/src/ripple/protocol/impl/AccountID.cpp index de19b7563..fb85fb23e 100644 --- a/src/ripple/protocol/impl/AccountID.cpp +++ b/src/ripple/protocol/impl/AccountID.cpp @@ -199,8 +199,7 @@ std::string AccountIDCache::toBase58( AccountID const& id) const { - std::lock_guard< - std::mutex> lock(mutex_); + std::lock_guard lock(mutex_); auto iter = m1_.find(id); if (iter != m1_.end()) return iter->second; diff --git a/src/ripple/resource/impl/Logic.h b/src/ripple/resource/impl/Logic.h index 824a2f877..a620c8c5a 100644 --- a/src/ripple/resource/impl/Logic.h +++ b/src/ripple/resource/impl/Logic.h @@ -112,7 +112,7 @@ public: Entry* entry (nullptr); { - std::lock_guard _(lock_); + std::lock_guard _(lock_); auto result = table_.emplace (std::piecewise_construct, std::make_tuple (kindInbound, address.at_port (0)), // Key @@ -143,7 +143,7 @@ public: Entry* entry (nullptr); { - std::lock_guard _(lock_); + std::lock_guard _(lock_); auto result = table_.emplace (std::piecewise_construct, std::make_tuple (kindOutbound, address), // Key @@ -177,7 +177,7 @@ public: Entry* entry (nullptr); { - std::lock_guard _(lock_); + std::lock_guard _(lock_); auto result = table_.emplace (std::piecewise_construct, std::make_tuple (kindUnlimited, address.at_port(1)),// Key @@ -212,7 +212,7 @@ public: clock_type::time_point const now (m_clock.now()); Json::Value ret (Json::objectValue); - std::lock_guard _(lock_); + std::lock_guard _(lock_); for (auto& inboundEntry : inbound_) { @@ -259,7 +259,7 @@ public: clock_type::time_point const now (m_clock.now()); Gossip gossip; - std::lock_guard _(lock_); + std::lock_guard _(lock_); gossip.items.reserve (inbound_.size()); @@ -283,7 +283,7 @@ public: { auto const elapsed = m_clock.now(); { - std::lock_guard _(lock_); + std::lock_guard _(lock_); auto result = importTable_.emplace (std::piecewise_construct, std::make_tuple(origin), // Key @@ -339,7 +339,7 @@ public: // void periodicActivity () { - std::lock_guard _(lock_); + std::lock_guard _(lock_); auto const elapsed = m_clock.now(); @@ -394,7 +394,7 @@ public: void erase (Table::iterator iter) { - std::lock_guard _(lock_); + std::lock_guard _(lock_); Entry& entry (iter->second); assert (entry.refcount == 0); inactive_.erase ( @@ -404,13 +404,13 @@ public: void acquire (Entry& entry) { - std::lock_guard _(lock_); + std::lock_guard _(lock_); ++entry.refcount; } void release (Entry& entry) { - std::lock_guard _(lock_); + std::lock_guard _(lock_); if (--entry.refcount == 0) { JLOG(m_journal.debug()) << @@ -441,7 +441,7 @@ public: Disposition charge (Entry& entry, Charge const& fee) { - std::lock_guard _(lock_); + std::lock_guard _(lock_); clock_type::time_point const now (m_clock.now()); int const balance (entry.add (fee.cost(), now)); JLOG(m_journal.trace()) << @@ -454,7 +454,7 @@ public: if (entry.isUnlimited()) return false; - std::lock_guard _(lock_); + std::lock_guard _(lock_); bool notify (false); auto const elapsed = m_clock.now(); if (entry.balance (m_clock.now()) >= warningThreshold && @@ -477,7 +477,7 @@ public: if (entry.isUnlimited()) return false; - std::lock_guard _(lock_); + std::lock_guard _(lock_); bool drop (false); clock_type::time_point const now (m_clock.now()); int const balance (entry.balance (now)); @@ -500,7 +500,7 @@ public: int balance (Entry& entry) { - std::lock_guard _(lock_); + std::lock_guard _(lock_); return entry.balance (m_clock.now()); } @@ -527,7 +527,7 @@ public: { clock_type::time_point const now (m_clock.now()); - std::lock_guard _(lock_); + std::lock_guard _(lock_); { beast::PropertyStream::Set s ("inbound", map); diff --git a/src/ripple/resource/impl/ResourceManager.cpp b/src/ripple/resource/impl/ResourceManager.cpp index 6c550e2c4..30f70f867 100644 --- a/src/ripple/resource/impl/ResourceManager.cpp +++ b/src/ripple/resource/impl/ResourceManager.cpp @@ -59,7 +59,7 @@ public: ~ManagerImp () override { { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); stop_ = true; cond_.notify_one(); } diff --git a/src/ripple/rpc/handlers/Connect.cpp b/src/ripple/rpc/handlers/Connect.cpp index 47bfd026b..7e3cd9b50 100644 --- a/src/ripple/rpc/handlers/Connect.cpp +++ b/src/ripple/rpc/handlers/Connect.cpp @@ -25,7 +25,6 @@ #include #include #include -#include namespace ripple { diff --git a/src/ripple/rpc/handlers/ConsensusInfo.cpp b/src/ripple/rpc/handlers/ConsensusInfo.cpp index 3d79d53fb..96512f0c5 100644 --- a/src/ripple/rpc/handlers/ConsensusInfo.cpp +++ b/src/ripple/rpc/handlers/ConsensusInfo.cpp @@ -22,7 +22,6 @@ #include #include #include -#include namespace ripple { diff --git a/src/ripple/rpc/handlers/LedgerAccept.cpp b/src/ripple/rpc/handlers/LedgerAccept.cpp index 4b9270c54..7587f8ef9 100644 --- a/src/ripple/rpc/handlers/LedgerAccept.cpp +++ b/src/ripple/rpc/handlers/LedgerAccept.cpp @@ -26,13 +26,14 @@ #include #include #include -#include + +#include namespace ripple { Json::Value doLedgerAccept (RPC::Context& context) { - auto lock = make_lock(context.app.getMasterMutex()); + std::unique_lock lock{context.app.getMasterMutex()}; Json::Value jvResult; if (!context.app.config().standalone()) diff --git a/src/ripple/rpc/handlers/Peers.cpp b/src/ripple/rpc/handlers/Peers.cpp index 628da745c..d18c2fd0f 100644 --- a/src/ripple/rpc/handlers/Peers.cpp +++ b/src/ripple/rpc/handlers/Peers.cpp @@ -24,7 +24,6 @@ #include #include #include -#include namespace ripple { diff --git a/src/ripple/rpc/handlers/Stop.cpp b/src/ripple/rpc/handlers/Stop.cpp index 79d6220f5..c7d500b81 100644 --- a/src/ripple/rpc/handlers/Stop.cpp +++ b/src/ripple/rpc/handlers/Stop.cpp @@ -20,7 +20,8 @@ #include #include #include -#include + +#include namespace ripple { @@ -30,7 +31,7 @@ struct Context; Json::Value doStop (RPC::Context& context) { - auto lock = make_lock(context.app.getMasterMutex()); + std::unique_lock lock{context.app.getMasterMutex()}; context.app.signalStop (); return RPC::makeObjectValue (systemName () + " server stopping"); diff --git a/src/ripple/rpc/handlers/UnlList.cpp b/src/ripple/rpc/handlers/UnlList.cpp index c063a42c7..ff016421d 100644 --- a/src/ripple/rpc/handlers/UnlList.cpp +++ b/src/ripple/rpc/handlers/UnlList.cpp @@ -21,7 +21,6 @@ #include #include #include -#include namespace ripple { diff --git a/src/ripple/rpc/impl/ServerHandlerImp.cpp b/src/ripple/rpc/impl/ServerHandlerImp.cpp index 3ca3c965d..c764bf7fa 100644 --- a/src/ripple/rpc/impl/ServerHandlerImp.cpp +++ b/src/ripple/rpc/impl/ServerHandlerImp.cpp @@ -153,7 +153,7 @@ bool ServerHandlerImp::onAccept (Session& session, boost::asio::ip::tcp::endpoint endpoint) { - std::lock_guard lock(countlock_); + std::lock_guard lock(countlock_); auto const c = ++count_[session.port()]; @@ -367,7 +367,7 @@ void ServerHandlerImp::onClose (Session& session, boost::system::error_code const&) { - std::lock_guard lock(countlock_); + std::lock_guard lock(countlock_); --count_[session.port()]; } diff --git a/src/ripple/rpc/impl/ShardArchiveHandler.cpp b/src/ripple/rpc/impl/ShardArchiveHandler.cpp index c776a80bd..13fa26bf8 100644 --- a/src/ripple/rpc/impl/ShardArchiveHandler.cpp +++ b/src/ripple/rpc/impl/ShardArchiveHandler.cpp @@ -45,7 +45,7 @@ ShardArchiveHandler::ShardArchiveHandler(Application& app, bool validate) ShardArchiveHandler::~ShardArchiveHandler() { - std::lock_guard lock(m_); + std::lock_guard lock(m_); timer_.cancel(); for (auto const& ar : archives_) app_.getShardStore()->removePreShard(ar.first); @@ -66,7 +66,7 @@ ShardArchiveHandler::~ShardArchiveHandler() bool ShardArchiveHandler::add(std::uint32_t shardIndex, parsedURL&& url) { - std::lock_guard lock(m_); + std::lock_guard lock(m_); if (process_) { JLOG(j_.error()) << @@ -86,7 +86,7 @@ ShardArchiveHandler::add(std::uint32_t shardIndex, parsedURL&& url) bool ShardArchiveHandler::start() { - std::lock_guard lock(m_); + std::lock_guard lock(m_); if (!app_.getShardStore()) { JLOG(j_.error()) << @@ -181,7 +181,7 @@ void ShardArchiveHandler::complete(path dstPath) { { - std::lock_guard lock(m_); + std::lock_guard lock(m_); try { if (!is_regular_file(dstPath)) @@ -214,7 +214,7 @@ ShardArchiveHandler::complete(path dstPath) auto const mode {ptr->app_.getOPs().getOperatingMode()}; if (ptr->validate_ && mode != NetworkOPs::omFULL) { - std::lock_guard lock(m_); + std::lock_guard lock(m_); timer_.expires_from_now(static_cast( (NetworkOPs::omFULL - mode) * 10)); timer_.async_wait( @@ -228,7 +228,7 @@ ShardArchiveHandler::complete(path dstPath) else { ptr->process(dstPath); - std::lock_guard lock(m_); + std::lock_guard lock(m_); remove(lock); next(lock); } @@ -240,7 +240,7 @@ ShardArchiveHandler::process(path const& dstPath) { std::uint32_t shardIndex; { - std::lock_guard lock(m_); + std::lock_guard lock(m_); shardIndex = archives_.begin()->first; } diff --git a/src/ripple/server/impl/BaseHTTPPeer.h b/src/ripple/server/impl/BaseHTTPPeer.h index 4b1e1a662..05437182c 100644 --- a/src/ripple/server/impl/BaseHTTPPeer.h +++ b/src/ripple/server/impl/BaseHTTPPeer.h @@ -360,7 +360,7 @@ on_write(error_code const& ec, return fail(ec, "write"); bytes_out_ += bytes_transferred; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); wq2_.clear(); wq2_.reserve(wq_.size()); std::swap(wq2_, wq_); @@ -445,7 +445,7 @@ write( return; if([&] { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); wq_.emplace_back(buf, bytes); return wq_.size() == 1 && wq2_.size() == 0; }()) @@ -507,7 +507,7 @@ complete() complete_ = true; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if(! wq_.empty() && ! wq2_.empty()) return; } @@ -542,7 +542,7 @@ close(bool graceful) { graceful_ = true; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if(! wq_.empty() || ! wq2_.empty()) return; } diff --git a/src/ripple/server/impl/io_list.h b/src/ripple/server/impl/io_list.h index faff29ed9..3620569dc 100644 --- a/src/ripple/server/impl/io_list.h +++ b/src/ripple/server/impl/io_list.h @@ -183,8 +183,7 @@ io_list::work::destroy() return; std::function f; { - std::lock_guard< - std::mutex> lock(ios_->m_); + std::lock_guard lock(ios_->m_); ios_->map_.erase(this); if(--ios_->n_ == 0 && ios_->closed_) @@ -217,7 +216,7 @@ io_list::emplace(Args&&... args) std::forward(args)...); decltype(sp) dead; - std::lock_guard lock(m_); + std::lock_guard lock(m_); if(! closed_) { ++n_; diff --git a/src/ripple/shamap/impl/SHAMapTreeNode.cpp b/src/ripple/shamap/impl/SHAMapTreeNode.cpp index 03ddbc7cd..07e87fe4d 100644 --- a/src/ripple/shamap/impl/SHAMapTreeNode.cpp +++ b/src/ripple/shamap/impl/SHAMapTreeNode.cpp @@ -43,7 +43,7 @@ SHAMapInnerNode::clone(std::uint32_t seq) const p->mIsBranch = mIsBranch; p->mFullBelowGen = mFullBelowGen; p->mHashes = mHashes; - std::lock_guard lock(childLock); + std::lock_guard lock(childLock); for (int i = 0; i < 16; ++i) { p->mChildren[i] = mChildren[i]; @@ -62,7 +62,7 @@ SHAMapInnerNodeV2::clone(std::uint32_t seq) const p->mHashes = mHashes; p->common_ = common_; p->depth_ = depth_; - std::lock_guard lock(childLock); + std::lock_guard lock(childLock); for (int i = 0; i < 16; ++i) { p->mChildren[i] = mChildren[i]; @@ -686,7 +686,7 @@ SHAMapInnerNode::getChildPointer (int branch) assert (branch >= 0 && branch < 16); assert (isInner()); - std::lock_guard lock (childLock); + std::lock_guard lock (childLock); return mChildren[branch].get (); } @@ -696,7 +696,7 @@ SHAMapInnerNode::getChild (int branch) assert (branch >= 0 && branch < 16); assert (isInner()); - std::lock_guard lock (childLock); + std::lock_guard lock (childLock); return mChildren[branch]; } @@ -708,7 +708,7 @@ SHAMapInnerNode::canonicalizeChild(int branch, std::shared_ptrgetNodeHash() == mHashes[branch]); - std::lock_guard lock (childLock); + std::lock_guard lock (childLock); if (mChildren[branch]) { // There is already a node hooked up, return it @@ -732,7 +732,7 @@ SHAMapInnerNodeV2::canonicalizeChild(int branch, std::shared_ptrgetNodeHash() == mHashes[branch]); - std::lock_guard lock (childLock); + std::lock_guard lock (childLock); if (mChildren[branch]) { // There is already a node hooked up, return it diff --git a/src/test/app/Path_test.cpp b/src/test/app/Path_test.cpp index fb444e3c9..2da35c0a0 100644 --- a/src/test/app/Path_test.cpp +++ b/src/test/app/Path_test.cpp @@ -213,7 +213,7 @@ public: void signal() { - std::lock_guard lk(mutex_); + std::lock_guard lk(mutex_); signaled_ = true; cv_.notify_all(); } diff --git a/src/test/beast/beast_io_latency_probe_test.cpp b/src/test/beast/beast_io_latency_probe_test.cpp index c8f664724..f99a37dd9 100644 --- a/src/test/beast/beast_io_latency_probe_test.cpp +++ b/src/test/beast/beast_io_latency_probe_test.cpp @@ -78,7 +78,7 @@ class io_latency_probe_test : wait_err = ec; auto const end {MeasureClock::now()}; elapsed_times_.emplace_back (end-start); - std::lock_guard lk{mtx}; + std::lock_guard lk{mtx}; done = true; cv.notify_one(); }); diff --git a/src/test/core/Coroutine_test.cpp b/src/test/core/Coroutine_test.cpp index b015d7f61..252d58a90 100644 --- a/src/test/core/Coroutine_test.cpp +++ b/src/test/core/Coroutine_test.cpp @@ -52,7 +52,7 @@ public: void signal() { - std::lock_guard lk(mutex_); + std::lock_guard lk(mutex_); signaled_ = true; cv_.notify_all(); } diff --git a/src/test/core/Workers_test.cpp b/src/test/core/Workers_test.cpp index abf6639a9..cf3edcc84 100644 --- a/src/test/core/Workers_test.cpp +++ b/src/test/core/Workers_test.cpp @@ -90,7 +90,7 @@ public: { void processTask(int instance) override { - std::lock_guard lk{mut}; + std::lock_guard lk{mut}; if (--count == 0) cv.notify_all(); } diff --git a/src/test/jtx/impl/ManualTimeKeeper.cpp b/src/test/jtx/impl/ManualTimeKeeper.cpp index 08d00bf62..9ae72a252 100644 --- a/src/test/jtx/impl/ManualTimeKeeper.cpp +++ b/src/test/jtx/impl/ManualTimeKeeper.cpp @@ -39,7 +39,7 @@ auto ManualTimeKeeper::now() const -> time_point { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); return now_; } @@ -47,7 +47,7 @@ auto ManualTimeKeeper::closeTime() const -> time_point { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); return now_ + closeOffset_; } @@ -58,7 +58,7 @@ ManualTimeKeeper::adjustCloseTime( // Copied from TimeKeeper::adjustCloseTime using namespace std::chrono; auto const s = amount.count(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); // Take large offsets, ignore small offsets, // push the close time towards our wall time. if (s > 1) @@ -78,14 +78,14 @@ ManualTimeKeeper::nowOffset() const std::chrono::duration ManualTimeKeeper::closeOffset() const { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); return closeOffset_; } void ManualTimeKeeper::set (time_point now) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); now_ = now; } diff --git a/src/test/jtx/impl/WSClient.cpp b/src/test/jtx/impl/WSClient.cpp index 74b276e5f..f7ff1d893 100644 --- a/src/test/jtx/impl/WSClient.cpp +++ b/src/test/jtx/impl/WSClient.cpp @@ -284,7 +284,7 @@ private: auto m = std::make_shared( std::move(jv)); { - std::lock_guard lock(m_); + std::lock_guard lock(m_); msgs_.push_front(m); cv_.notify_all(); } @@ -297,7 +297,7 @@ private: void on_read_done() { - std::lock_guard lock(m0_); + std::lock_guard lock(m0_); b0_ = true; cv0_.notify_all(); } diff --git a/src/test/overlay/short_read_test.cpp b/src/test/overlay/short_read_test.cpp index d02fcfaf7..ea94867b5 100644 --- a/src/test/overlay/short_read_test.cpp +++ b/src/test/overlay/short_read_test.cpp @@ -116,14 +116,14 @@ private: void add (std::shared_ptr const& child) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); list_.emplace(child.get(), child); } void remove (Child* child) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); list_.erase(child); if (list_.empty()) cond_.notify_one(); @@ -134,7 +134,7 @@ private: { std::vector> v; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); v.reserve(list_.size()); if (closed_) return; diff --git a/src/test/unit_test/multi_runner.cpp b/src/test/unit_test/multi_runner.cpp index c26f0e333..203851416 100644 --- a/src/test/unit_test/multi_runner.cpp +++ b/src/test/unit_test/multi_runner.cpp @@ -200,7 +200,7 @@ template void multi_runner_base::inner::add(results const& r) { - std::lock_guard l{m_}; + std::lock_guard l{m_}; results_.merge(r); } @@ -209,7 +209,7 @@ template void multi_runner_base::inner::print_results(S& s) { - std::lock_guard l{m_}; + std::lock_guard l{m_}; results_.print(s); } @@ -341,7 +341,7 @@ void multi_runner_base::message_queue_send(MessageType mt, std::string const& s) { // must use a mutex since the two "sends" must happen in order - std::lock_guard l{inner_->m_}; + std::lock_guard l{inner_->m_}; message_queue_->send(&mt, sizeof(mt), /*priority*/ 0); message_queue_->send(s.c_str(), s.size(), /*priority*/ 0); }