mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Do the tryLocal/addPeers operations on an InboundLedger without the collection lock.
This commit is contained in:
@@ -58,6 +58,27 @@ InboundLedger::~InboundLedger ()
|
||||
{
|
||||
}
|
||||
|
||||
void InboundLedger::init(ScopedLockType& collectionLock, bool couldBeNew)
|
||||
{
|
||||
ScopedLockType sl (mLock, __FILE__, __LINE__);
|
||||
collectionLock.unlock ();
|
||||
|
||||
if (!tryLocal ())
|
||||
{
|
||||
addPeers ();
|
||||
setTimer ();
|
||||
}
|
||||
else if (!isFailed ())
|
||||
{
|
||||
WriteLog (lsDEBUG, InboundLedger) << "Acquiring ledger we already have locally: " << getHash ();
|
||||
mLedger->setClosed ();
|
||||
mLedger->setImmutable ();
|
||||
getApp ().getLedgerMaster ().storeLedger (mLedger);
|
||||
if (couldBeNew)
|
||||
getApp ().getLedgerMaster ().checkAccept (mLedger);
|
||||
}
|
||||
}
|
||||
|
||||
bool InboundLedger::tryLocal ()
|
||||
{
|
||||
// return value: true = no more work to do
|
||||
|
||||
@@ -83,6 +83,7 @@ public:
|
||||
void awaitData ();
|
||||
void noAwaitData ();
|
||||
bool checkLocal ();
|
||||
void init(ScopedLockType& collectionLock, bool couldBeNew);
|
||||
|
||||
typedef std::pair <protocol::TMGetObjectByHash::ObjectType, uint256> neededHash_t;
|
||||
|
||||
|
||||
@@ -48,22 +48,7 @@ InboundLedger::pointer InboundLedgers::findCreate (uint256 const& hash, uint32 s
|
||||
ret = boost::make_shared<InboundLedger> (hash, seq);
|
||||
assert (ret);
|
||||
mLedgers.insert (std::make_pair (hash, ret));
|
||||
|
||||
if (!ret->tryLocal())
|
||||
{
|
||||
ret->addPeers ();
|
||||
ret->setTimer (); // Cannot call in constructor
|
||||
}
|
||||
else if (!ret->isFailed ())
|
||||
{
|
||||
WriteLog (lsDEBUG, InboundLedger) << "Acquiring ledger we already have locally: " << hash;
|
||||
Ledger::pointer ledger = ret->getLedger ();
|
||||
ledger->setClosed ();
|
||||
ledger->setImmutable ();
|
||||
getApp().getLedgerMaster ().storeLedger (ledger);
|
||||
if (couldBeNew)
|
||||
getApp().getLedgerMaster().checkAccept(ledger);
|
||||
}
|
||||
ret->init (sl, couldBeNew);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
private:
|
||||
typedef boost::unordered_map <uint256, InboundLedger::pointer> MapType;
|
||||
|
||||
typedef RippleMutex LockType;
|
||||
typedef RippleRecursiveMutex LockType;
|
||||
typedef LockType::ScopedLockType ScopedLockType;
|
||||
LockType mLock;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user