[net processing] Change cs_main TRY_LOCK to LOCK in SendMessages()

This was changed to TRY_LOCK in #1117 to fix a potential deadlock
between cs_main and cs_vSend. cs_vSend was split into cs_vSend and
cs_sendProcessing in #9535 (and cs_sendProcessing was changed from a
TRY_LOCK to a LOCK in the same PR).

Since cs_vSend can no longer be taken before cs_main, revert this to a
LOCK().

This commit leaves part of the code with bad indentation. That is fixed
by the next (whitespace change only) commit.
pull/764/head
John Newbery 4 years ago
parent c0b0b0240f
commit 1a1c23f8d4

@ -3838,7 +3838,7 @@ public:
bool PeerLogicValidation::SendMessages(CNode* pto)
{
const Consensus::Params& consensusParams = Params().GetConsensus();
{
// Don't send anything until the version handshake is complete
if (!pto->fSuccessfullyConnected || pto->fDisconnect)
return true;
@ -3875,9 +3875,8 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
}
}
TRY_LOCK(cs_main, lockMain);
if (!lockMain)
return true;
{
LOCK(cs_main);
if (MaybeDiscourageAndDisconnect(*pto)) return true;
@ -4416,7 +4415,7 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
pto->m_tx_relay->nextSendTimeFeeFilter = timeNow + GetRandInt(MAX_FEEFILTER_CHANGE_DELAY) * 1000000;
}
}
}
} // release cs_main
return true;
}

Loading…
Cancel
Save