Skip to content

Commit 1a1c23f

Browse files
committed
[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.
1 parent c0b0b02 commit 1a1c23f

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/net_processing.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3838,7 +3838,7 @@ class CompareInvMempoolOrder
38383838
bool PeerLogicValidation::SendMessages(CNode* pto)
38393839
{
38403840
const Consensus::Params& consensusParams = Params().GetConsensus();
3841-
{
3841+
38423842
// Don't send anything until the version handshake is complete
38433843
if (!pto->fSuccessfullyConnected || pto->fDisconnect)
38443844
return true;
@@ -3875,9 +3875,8 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
38753875
}
38763876
}
38773877

3878-
TRY_LOCK(cs_main, lockMain);
3879-
if (!lockMain)
3880-
return true;
3878+
{
3879+
LOCK(cs_main);
38813880

38823881
if (MaybeDiscourageAndDisconnect(*pto)) return true;
38833882

@@ -4416,7 +4415,7 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
44164415
pto->m_tx_relay->nextSendTimeFeeFilter = timeNow + GetRandInt(MAX_FEEFILTER_CHANGE_DELAY) * 1000000;
44174416
}
44184417
}
4419-
}
4418+
} // release cs_main
44204419
return true;
44214420
}
44224421

0 commit comments

Comments
 (0)