diff options
| author | John Newbery <[email protected]> | 2020-06-15 10:15:08 -0400 |
|---|---|---|
| committer | John Newbery <[email protected]> | 2020-07-10 18:20:07 +0100 |
| commit | 1a1c23f8d40116741f0e26cdf22688fd91c923fc (patch) | |
| tree | 4af484dc616b21654a000f9938e2554406c3af1c /src/net_processing.cpp | |
| parent | Merge #14033: p2p: Drop CADDR_TIME_VERSION checks now that MIN_PEER_PROTO_VER... (diff) | |
| download | discoin-1a1c23f8d40116741f0e26cdf22688fd91c923fc.tar.xz discoin-1a1c23f8d40116741f0e26cdf22688fd91c923fc.zip | |
[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.
Diffstat (limited to 'src/net_processing.cpp')
| -rw-r--r-- | src/net_processing.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 8ef79cd71..f5cff6297 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -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; } |