mRecentPositions must be protected by the master lock.

This commit is contained in:
JoelKatz
2014-03-28 13:45:15 -07:00
parent cc5466d450
commit 5a21269da4
2 changed files with 8 additions and 5 deletions

View File

@@ -520,7 +520,7 @@ public:
&getApp().getInboundLedgers(),
mPrevLedgerHash, 0, InboundLedger::fcCONSENSUS));
mHaveCorrectLCL = false;
}
}
return;
}
@@ -851,15 +851,16 @@ private:
*/
void accept (SHAMap::pointer set)
{
if (set->getHash ().isNonZero ())
// put our set where others can get it later
getApp().getOPs ().takePosition (mPreviousLedger
->getLedgerSeq (), set);
{
Application::ScopedLockType lock
(getApp ().getMasterLock ());
// put our set where others can get it later
if (set->getHash ().isNonZero ())
getApp().getOPs ().takePosition (
mPreviousLedger->getLedgerSeq (), set);
assert (set->getHash () == mOurPosition->getCurrentHash ());
// these are now obsolete
getApp().getOPs ().peekStoredProposals ().clear ();

View File

@@ -1561,6 +1561,7 @@ void NetworkOPsImp::processTrustedProposal (LedgerProposal::pointer proposal,
}
}
// Must be called while holding the master lock
SHAMap::pointer NetworkOPsImp::getTXMap (uint256 const& hash)
{
std::map<uint256, std::pair<int, SHAMap::pointer> >::iterator it = mRecentPositions.find (hash);
@@ -1574,6 +1575,7 @@ SHAMap::pointer NetworkOPsImp::getTXMap (uint256 const& hash)
return mConsensus->getTransactionTree (hash, false);
}
// Must be called while holding the master lock
void NetworkOPsImp::takePosition (int seq, SHAMap::ref position)
{
mRecentPositions[position->getHash ()] = std::make_pair (seq, position);