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