diff options
author | MarcoFalke <falke.marco@gmail.com> | 2019-02-08 08:58:27 -0500 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2019-02-08 08:58:29 -0500 |
commit | 30495d1e756c2bb0ff8bbc72372abd1678dd1253 (patch) | |
tree | 1339329d1a43d05945429693eb8db8573a719026 /src/net.h | |
parent | 6fc656a410b6fa469be258414f1e26cd4b6025af (diff) | |
parent | eea02be70ee37b845f2719b3c08e5baf4b6f51f6 (diff) |
Merge #15201: net: Add missing locking annotation for vNodes. vNodes is guarded by cs_vNodes.
eea02be70e Add locking annotation for vNodes. vNodes is guarded by cs_vNodes. (practicalswift)
Pull request description:
Add locking annotation for `vNodes`. `vNodes` is guarded by `cs_vNodes`.
Tree-SHA512: b1e18be22ba5b9dd153536380321b09b30a75a20575f975af9af94164f51982b32267ba0994e77c801513b59da05d923a974a9d2dfebdac48024c4bda98b53af
Diffstat (limited to 'src/net.h')
-rw-r--r-- | src/net.h | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -174,7 +174,18 @@ public: CConnman(uint64_t seed0, uint64_t seed1); ~CConnman(); bool Start(CScheduler& scheduler, const Options& options); - void Stop(); + + // TODO: Remove NO_THREAD_SAFETY_ANALYSIS. Lock cs_vNodes before reading the variable vNodes. + // + // When removing NO_THREAD_SAFETY_ANALYSIS be aware of the following lock order requirements: + // * CheckForStaleTipAndEvictPeers locks cs_main before indirectly calling GetExtraOutboundCount + // which locks cs_vNodes. + // * ProcessMessage locks cs_main and g_cs_orphans before indirectly calling ForEachNode which + // locks cs_vNodes. + // + // Thus the implicit locking order requirement is: (1) cs_main, (2) g_cs_orphans, (3) cs_vNodes. + void Stop() NO_THREAD_SAFETY_ANALYSIS; + void Interrupt(); bool GetNetworkActive() const { return fNetworkActive; }; bool GetUseAddrmanOutgoing() const { return m_use_addrman_outgoing; }; @@ -382,7 +393,7 @@ private: CCriticalSection cs_vOneShots; std::vector<std::string> vAddedNodes GUARDED_BY(cs_vAddedNodes); CCriticalSection cs_vAddedNodes; - std::vector<CNode*> vNodes; + std::vector<CNode*> vNodes GUARDED_BY(cs_vNodes); std::list<CNode*> vNodesDisconnected; mutable CCriticalSection cs_vNodes; std::atomic<NodeId> nLastNodeId{0}; |