diff options
author | practicalswift <practicalswift@users.noreply.github.com> | 2019-01-19 14:49:29 +0100 |
---|---|---|
committer | practicalswift <practicalswift@users.noreply.github.com> | 2019-01-19 18:23:53 +0100 |
commit | eea02be70ee37b845f2719b3c08e5baf4b6f51f6 (patch) | |
tree | 0223ed7ec339fa7d73d0e0d9f5d4a0873c8cb18f /src/net.h | |
parent | 63144335becb705a233b32fb8d63f37b7d62071a (diff) |
Add locking annotation for vNodes. vNodes is guarded by cs_vNodes.
Diffstat (limited to 'src/net.h')
-rw-r--r-- | src/net.h | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -177,7 +177,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; }; @@ -418,7 +429,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}; |