fixed potential deadlock in CMasternodePing::SimpleCheck (#1534)

This commit is contained in:
Ilya Savinov 2017-07-17 16:59:04 +03:00 committed by UdjinM6
parent 9e9df28203
commit e0d6c5b5a2
2 changed files with 2 additions and 2 deletions

View File

@ -821,7 +821,7 @@ bool CMasternodePing::SimpleCheck(int& nDos)
} }
{ {
LOCK(cs_main); AssertLockHeld(cs_main);
BlockMap::iterator mi = mapBlockIndex.find(blockHash); BlockMap::iterator mi = mapBlockIndex.find(blockHash);
if (mi == mapBlockIndex.end()) { if (mi == mapBlockIndex.end()) {
LogPrint("masternode", "CMasternodePing::SimpleCheck -- Masternode ping is invalid, unknown block hash: masternode=%s blockHash=%s\n", vin.prevout.ToStringShort(), blockHash.ToString()); LogPrint("masternode", "CMasternodePing::SimpleCheck -- Masternode ping is invalid, unknown block hash: masternode=%s blockHash=%s\n", vin.prevout.ToStringShort(), blockHash.ToString());

View File

@ -1382,7 +1382,7 @@ std::string CMasternodeMan::ToString() const
void CMasternodeMan::UpdateMasternodeList(CMasternodeBroadcast mnb) void CMasternodeMan::UpdateMasternodeList(CMasternodeBroadcast mnb)
{ {
LOCK(cs); LOCK2(cs_main, cs);
mapSeenMasternodePing.insert(std::make_pair(mnb.lastPing.GetHash(), mnb.lastPing)); mapSeenMasternodePing.insert(std::make_pair(mnb.lastPing.GetHash(), mnb.lastPing));
mapSeenMasternodeBroadcast.insert(std::make_pair(mnb.GetHash(), std::make_pair(GetTime(), mnb))); mapSeenMasternodeBroadcast.insert(std::make_pair(mnb.GetHash(), std::make_pair(GetTime(), mnb)));