From 7d96075e14ec95a39f154e6faacec1f234f62c0b Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Sun, 21 Jun 2015 22:12:06 -0700 Subject: [PATCH] Avoid lock overlap: Prefer to release the InboundLedgers lock before acquiring a lock on a specific ledger --- src/ripple/app/ledger/impl/InboundLedgers.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ripple/app/ledger/impl/InboundLedgers.cpp b/src/ripple/app/ledger/impl/InboundLedgers.cpp index 87a536fb5f..fdd61f91c1 100644 --- a/src/ripple/app/ledger/impl/InboundLedgers.cpp +++ b/src/ripple/app/ledger/impl/InboundLedgers.cpp @@ -58,6 +58,7 @@ public: Ledger::pointer acquire (uint256 const& hash, std::uint32_t seq, InboundLedger::fcReason reason) { assert (hash.isNonZero ()); + bool isNew = true; InboundLedger::pointer inbound; { ScopedLockType sl (mLock); @@ -67,12 +68,8 @@ public: auto it = mLedgers.find (hash); if (it != mLedgers.end ()) { + isNew = false; inbound = it->second; - - // If the acquisition failed, don't mark the item as - // recently accessed so that it can expire. - if (! inbound->isFailed ()) - inbound->update (seq); } else { @@ -84,6 +81,9 @@ public: } } } + if (inbound && ! isNew && ! inbound->isFailed ()) + inbound->update (seq); + if (inbound && inbound->isComplete ()) return inbound->getLedger(); return {};