aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2022-03-28 08:23:32 +0100
committerJohn Newbery <john@johnnewbery.com>2022-03-28 08:23:32 +0100
commit21154ff9270e4bbae02d9012a4a73cce86a00334 (patch)
tree8cade88dec8f8e248c22722d2af93118f54d27f1 /src
parent3297f5c11c72dd83479ff8335e047555e3f8cb3b (diff)
net_processing: move CNode data access out of lock
CNode::m_relays_tx and CNode::m_bloom_filter_loaded access don't require the Peer::TxRelay::m_bloom_filter_mutex lock, so move them out of the lock scope. See https://github.com/bitcoin/bitcoin/pull/21160#discussion_r736785417 and https://github.com/bitcoin/bitcoin/pull/21160#discussion_r736785662.
Diffstat (limited to 'src')
-rw-r--r--src/net_processing.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 1df47fe3dd..195456bbf4 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -2715,8 +2715,10 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
pfrom.m_limited_node = (!(nServices & NODE_NETWORK) && (nServices & NODE_NETWORK_LIMITED));
if (peer->m_tx_relay != nullptr) {
- LOCK(peer->m_tx_relay->m_bloom_filter_mutex);
- peer->m_tx_relay->m_relay_txs = fRelay; // set to true after we get the first filter* message
+ {
+ LOCK(peer->m_tx_relay->m_bloom_filter_mutex);
+ peer->m_tx_relay->m_relay_txs = fRelay; // set to true after we get the first filter* message
+ }
if (fRelay) pfrom.m_relays_txs = true;
}
@@ -4030,10 +4032,12 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
}
else if (peer->m_tx_relay != nullptr)
{
- LOCK(peer->m_tx_relay->m_bloom_filter_mutex);
- peer->m_tx_relay->m_bloom_filter.reset(new CBloomFilter(filter));
+ {
+ LOCK(peer->m_tx_relay->m_bloom_filter_mutex);
+ peer->m_tx_relay->m_bloom_filter.reset(new CBloomFilter(filter));
+ peer->m_tx_relay->m_relay_txs = true;
+ }
pfrom.m_bloom_filter_loaded = true;
- peer->m_tx_relay->m_relay_txs = true;
pfrom.m_relays_txs = true;
}
return;
@@ -4076,10 +4080,13 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
if (peer->m_tx_relay == nullptr) {
return;
}
- LOCK(peer->m_tx_relay->m_bloom_filter_mutex);
- peer->m_tx_relay->m_bloom_filter = nullptr;
+
+ {
+ LOCK(peer->m_tx_relay->m_bloom_filter_mutex);
+ peer->m_tx_relay->m_bloom_filter = nullptr;
+ peer->m_tx_relay->m_relay_txs = true;
+ }
pfrom.m_bloom_filter_loaded = false;
- peer->m_tx_relay->m_relay_txs = true;
pfrom.m_relays_txs = true;
return;
}