aboutsummaryrefslogtreecommitdiff
path: root/src/net_processing.cpp
diff options
context:
space:
mode:
authorMacroFake <falke.marco@gmail.com>2022-08-30 11:34:52 +0200
committerMacroFake <falke.marco@gmail.com>2022-08-30 11:35:11 +0200
commitcfda740b332c77800f9bb2506d840dad3f4938c0 (patch)
tree85bacbd46a9e0fa8c9d9a9717ea8a90507e2c450 /src/net_processing.cpp
parente191fac4f3c37820f0618f72f0a8e8b524531ab8 (diff)
parent9816dc96b77fd9780bb97891cd45a1b9798db8f5 (diff)
downloadbitcoin-cfda740b332c77800f9bb2506d840dad3f4938c0.tar.xz
Merge bitcoin/bitcoin#25174: net/net_processing: Add thread safety related annotations for CNode and Peer
9816dc96b77fd9780bb97891cd45a1b9798db8f5 net: note CNode members that are treated as const (Anthony Towns) ef26f2f421071986a3878a1a94b0149ae8e16fcd net: mark CNode unique_ptr members as const (Anthony Towns) bbec32c9ad2fe213314db9d39aa1eacff2e0bc23 net: mark TransportSerializer/m_serializer as const (Anthony Towns) 06ebdc886fcb4ca22f695bafe0956cff6d70a250 net/net_processing: add missing thread safety annotations (Anthony Towns) Pull request description: Adds `GUARDED_BY` and `const` annotations to document how we currently ensure various members of `CNode` and `Peer` aren't subject to race conditions. ACKs for top commit: MarcoFalke: review ACK 9816dc96b77fd9780bb97891cd45a1b9798db8f5 📍 jonatack: utACK 9816dc96b77fd9780bb97891cd45a1b9798db8f5 hebasto: ACK 9816dc96b77fd9780bb97891cd45a1b9798db8f5, I have reviewed the code and it looks OK. In particular, I verified the usage of variables which got `GUARDED_BY` annotations. Tree-SHA512: fa95bca72435d79caadc736ee7687e505dbe8fbdb20690809e97666664a8d0dea39a7d17cf16f0437d7f5746b9ad98a466b26325d2913252c5d2b520b384b785
Diffstat (limited to 'src/net_processing.cpp')
-rw-r--r--src/net_processing.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index b83034463d..fff7f86d78 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -289,7 +289,7 @@ struct Peer {
* non-wtxid-relay peers, wtxid for wtxid-relay peers). We use the
* mempool to sort transactions in dependency order before relay, so
* this does not have to be sorted. */
- std::set<uint256> m_tx_inventory_to_send;
+ std::set<uint256> m_tx_inventory_to_send GUARDED_BY(m_tx_inventory_mutex);
/** Whether the peer has requested us to send our complete mempool. Only
* permitted if the peer has NetPermissionFlags::Mempool. See BIP35. */
bool m_send_mempool GUARDED_BY(m_tx_inventory_mutex){false};
@@ -648,7 +648,7 @@ private:
std::atomic<int> m_best_height{-1};
/** Next time to check for stale tip */
- std::chrono::seconds m_stale_tip_check_time{0s};
+ std::chrono::seconds m_stale_tip_check_time GUARDED_BY(cs_main){0s};
/** Whether this node is running in -blocksonly mode */
const bool m_ignore_incoming_txs;
@@ -657,7 +657,7 @@ private:
/** Whether we've completed initial sync yet, for determining when to turn
* on extra block-relay-only peers. */
- bool m_initial_sync_finished{false};
+ bool m_initial_sync_finished GUARDED_BY(cs_main){false};
/** Protects m_peer_map. This mutex must not be locked while holding a lock
* on any of the mutexes inside a Peer object. */