Skip to content

Commit fb561ef

Browse files
perf: convert m_nodes_mutex to a non-recursive mutex
1 parent ff1ddc9 commit fb561ef

File tree

2 files changed

+57
-59
lines changed

2 files changed

+57
-59
lines changed

src/net.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,6 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
536536
}
537537
// It is possible that we already have a connection to the IP/port pszDest resolved to.
538538
// In that case, drop the connection that was just created.
539-
LOCK(m_nodes_mutex);
540539
CNode* pnode = FindNode(static_cast<CService>(addrConnect));
541540
if (pnode) {
542541
LogPrintf("Not opening a connection to %s, already connected to %s\n", pszDest, addrConnect.ToStringAddrPort());
@@ -3810,7 +3809,7 @@ void CConnman::ThreadOpenMasternodeConnections(CDeterministicMNManager& dmnman,
38103809

38113810
auto getConnectToDmn = [&]() -> CDeterministicMNCPtr {
38123811
// don't hold lock while calling OpenMasternodeConnection as cs_main is locked deep inside
3813-
LOCK2(m_nodes_mutex, cs_vPendingMasternodes);
3812+
LOCK(cs_vPendingMasternodes);
38143813

38153814
if (!vPendingMasternodes.empty()) {
38163815
auto dmn = mnList.GetValidMN(vPendingMasternodes.front());
@@ -4797,7 +4796,6 @@ void CConnman::GetNodeStats(std::vector<CNodeStats>& vstats) const
47974796

47984797
bool CConnman::DisconnectNode(const std::string& strNode)
47994798
{
4800-
LOCK(m_nodes_mutex);
48014799
if (CNode* pnode = FindNode(strNode)) {
48024800
LogPrint(BCLog::NET_NETCONN, "disconnect by address%s matched peer=%d; disconnecting\n", (fLogIPs ? strprintf("=%s", strNode) : ""), pnode->GetId());
48034801
pnode->fDisconnect = true;

src/net.h

+56-56
Original file line numberDiff line numberDiff line change
@@ -1263,8 +1263,8 @@ friend class CNode;
12631263
EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex, !m_added_nodes_mutex, !m_addr_fetches_mutex, !mutexMsgProc);
12641264

12651265
void StopThreads();
1266-
void StopNodes();
1267-
void Stop()
1266+
void StopNodes() EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex);
1267+
void Stop() EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex)
12681268
{
12691269
StopThreads();
12701270
StopNodes();
@@ -1292,10 +1292,10 @@ friend class CNode;
12921292
const char* strDest, ConnectionType conn_type, bool use_v2transport,
12931293
MasternodeConn masternode_connection = MasternodeConn::IsNotConnection,
12941294
MasternodeProbeConn masternode_probe_connection = MasternodeProbeConn::IsNotConnection)
1295-
EXCLUSIVE_LOCKS_REQUIRED(!m_unused_i2p_sessions_mutex, !mutexMsgProc);
1295+
EXCLUSIVE_LOCKS_REQUIRED(!m_unused_i2p_sessions_mutex, !mutexMsgProc, !m_nodes_mutex);
12961296
void OpenMasternodeConnection(const CAddress& addrConnect, bool use_v2transport, MasternodeProbeConn probe = MasternodeProbeConn::IsConnection)
1297-
EXCLUSIVE_LOCKS_REQUIRED(!m_unused_i2p_sessions_mutex, !mutexMsgProc);
1298-
bool CheckIncomingNonce(uint64_t nonce);
1297+
EXCLUSIVE_LOCKS_REQUIRED(!m_unused_i2p_sessions_mutex, !mutexMsgProc, !m_nodes_mutex);
1298+
bool CheckIncomingNonce(uint64_t nonce) EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex);
12991299

13001300
// alias for thread safety annotations only, not defined
13011301
RecursiveMutex& GetNodesMutex() const LOCK_RETURNED(m_nodes_mutex);
@@ -1314,37 +1314,37 @@ friend class CNode;
13141314

13151315
constexpr static const CAllNodes AllNodes{};
13161316

1317-
bool ForNode(NodeId id, std::function<bool(const CNode* pnode)> cond, std::function<bool(CNode* pnode)> func);
1318-
bool ForNode(const CService& addr, std::function<bool(const CNode* pnode)> cond, std::function<bool(CNode* pnode)> func);
1317+
bool ForNode(NodeId id, std::function<bool(const CNode* pnode)> cond, std::function<bool(CNode* pnode)> func) EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex);
1318+
bool ForNode(const CService& addr, std::function<bool(const CNode* pnode)> cond, std::function<bool(CNode* pnode)> func) EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex);
13191319

13201320
template<typename Callable>
1321-
bool ForNode(const CService& addr, Callable&& func)
1321+
bool ForNode(const CService& addr, Callable&& func) EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex)
13221322
{
13231323
return ForNode(addr, FullyConnectedOnly, func);
13241324
}
13251325

13261326
template<typename Callable>
1327-
bool ForNode(NodeId id, Callable&& func)
1327+
bool ForNode(NodeId id, Callable&& func) EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex)
13281328
{
13291329
return ForNode(id, FullyConnectedOnly, func);
13301330
}
13311331

13321332
using NodeFn = std::function<void(CNode*)>;
13331333

1334-
bool IsConnected(const CService& addr, std::function<bool(const CNode* pnode)> cond)
1334+
bool IsConnected(const CService& addr, std::function<bool(const CNode* pnode)> cond) EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex)
13351335
{
13361336
return ForNode(addr, cond, [](CNode* pnode){
13371337
return true;
13381338
});
13391339
}
13401340

1341-
bool IsMasternodeOrDisconnectRequested(const CService& addr);
1341+
bool IsMasternodeOrDisconnectRequested(const CService& addr) EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex);
13421342

13431343
void PushMessage(CNode* pnode, CSerializedNetMsg&& msg)
13441344
EXCLUSIVE_LOCKS_REQUIRED(!mutexMsgProc, !m_total_bytes_sent_mutex);
13451345

13461346
template<typename Condition, typename Callable>
1347-
bool ForEachNodeContinueIf(const Condition& cond, Callable&& func)
1347+
bool ForEachNodeContinueIf(const Condition& cond, Callable&& func) EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex)
13481348
{
13491349
LOCK(m_nodes_mutex);
13501350
for (auto&& node : m_nodes)
@@ -1361,7 +1361,7 @@ friend class CNode;
13611361
}
13621362

13631363
template<typename Condition, typename Callable>
1364-
bool ForEachNodeContinueIf(const Condition& cond, Callable&& func) const
1364+
bool ForEachNodeContinueIf(const Condition& cond, Callable&& func) const EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex)
13651365
{
13661366
LOCK(m_nodes_mutex);
13671367
for (const auto& node : m_nodes)
@@ -1378,7 +1378,7 @@ friend class CNode;
13781378
}
13791379

13801380
template<typename Condition, typename Callable>
1381-
void ForEachNode(const Condition& cond, Callable&& func)
1381+
void ForEachNode(const Condition& cond, Callable&& func) EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex)
13821382
{
13831383
LOCK(m_nodes_mutex);
13841384
for (auto&& node : m_nodes) {
@@ -1387,13 +1387,13 @@ friend class CNode;
13871387
}
13881388
};
13891389

1390-
void ForEachNode(const NodeFn& fn)
1390+
void ForEachNode(const NodeFn& fn) EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex)
13911391
{
13921392
ForEachNode(FullyConnectedOnly, fn);
13931393
}
13941394

13951395
template<typename Condition, typename Callable>
1396-
void ForEachNode(const Condition& cond, Callable&& func) const
1396+
void ForEachNode(const Condition& cond, Callable&& func) const EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex)
13971397
{
13981398
LOCK(m_nodes_mutex);
13991399
for (auto&& node : m_nodes) {
@@ -1402,13 +1402,13 @@ friend class CNode;
14021402
}
14031403
};
14041404

1405-
void ForEachNode(const NodeFn& fn) const
1405+
void ForEachNode(const NodeFn& fn) const EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex)
14061406
{
14071407
ForEachNode(FullyConnectedOnly, fn);
14081408
}
14091409

14101410
template<typename Condition, typename Callable, typename CallableAfter>
1411-
void ForEachNodeThen(const Condition& cond, Callable&& pre, CallableAfter&& post)
1411+
void ForEachNodeThen(const Condition& cond, Callable&& pre, CallableAfter&& post) EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex)
14121412
{
14131413
LOCK(m_nodes_mutex);
14141414
for (auto&& node : m_nodes) {
@@ -1419,13 +1419,13 @@ friend class CNode;
14191419
};
14201420

14211421
template<typename Callable, typename CallableAfter>
1422-
void ForEachNodeThen(Callable&& pre, CallableAfter&& post)
1422+
void ForEachNodeThen(Callable&& pre, CallableAfter&& post) EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex)
14231423
{
14241424
ForEachNodeThen(FullyConnectedOnly, pre, post);
14251425
}
14261426

14271427
template<typename Condition, typename Callable, typename CallableAfter>
1428-
void ForEachNodeThen(const Condition& cond, Callable&& pre, CallableAfter&& post) const
1428+
void ForEachNodeThen(const Condition& cond, Callable&& pre, CallableAfter&& post) const EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex)
14291429
{
14301430
LOCK(m_nodes_mutex);
14311431
for (auto&& node : m_nodes) {
@@ -1475,14 +1475,14 @@ friend class CNode;
14751475
// return a value less than (num_outbound_connections - num_outbound_slots)
14761476
// in cases where some outbound connections are not yet fully connected, or
14771477
// not yet fully disconnected.
1478-
int GetExtraFullOutboundCount() const;
1478+
int GetExtraFullOutboundCount() const EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex);
14791479
// Count the number of block-relay-only peers we have over our limit.
1480-
int GetExtraBlockRelayCount() const;
1480+
int GetExtraBlockRelayCount() const EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex);
14811481

14821482
bool AddNode(const AddedNodeParams& add) EXCLUSIVE_LOCKS_REQUIRED(!m_added_nodes_mutex);
14831483
bool RemoveAddedNode(const std::string& node) EXCLUSIVE_LOCKS_REQUIRED(!m_added_nodes_mutex);
14841484
bool AddedNodesContain(const CAddress& addr) const EXCLUSIVE_LOCKS_REQUIRED(!m_added_nodes_mutex);
1485-
std::vector<AddedNodeInfo> GetAddedNodeInfo(bool include_connected) const EXCLUSIVE_LOCKS_REQUIRED(!m_added_nodes_mutex);
1485+
std::vector<AddedNodeInfo> GetAddedNodeInfo(bool include_connected) const EXCLUSIVE_LOCKS_REQUIRED(!m_added_nodes_mutex, !m_nodes_mutex);
14861486

14871487
/**
14881488
* Attempts to open a connection. Currently only used from tests.
@@ -1498,28 +1498,28 @@ friend class CNode;
14981498
* - Max connection capacity for type is filled
14991499
*/
15001500
bool AddConnection(const std::string& address, ConnectionType conn_type, bool use_v2transport)
1501-
EXCLUSIVE_LOCKS_REQUIRED(!m_unused_i2p_sessions_mutex, !mutexMsgProc);
1501+
EXCLUSIVE_LOCKS_REQUIRED(!m_unused_i2p_sessions_mutex, !mutexMsgProc, !m_nodes_mutex);
15021502

15031503
bool AddPendingMasternode(const uint256& proTxHash);
15041504
void SetMasternodeQuorumNodes(Consensus::LLMQType llmqType, const uint256& quorumHash, const std::set<uint256>& proTxHashes);
1505-
void SetMasternodeQuorumRelayMembers(Consensus::LLMQType llmqType, const uint256& quorumHash, const std::set<uint256>& proTxHashes);
1505+
void SetMasternodeQuorumRelayMembers(Consensus::LLMQType llmqType, const uint256& quorumHash, const std::set<uint256>& proTxHashes) EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex);
15061506
bool HasMasternodeQuorumNodes(Consensus::LLMQType llmqType, const uint256& quorumHash) const;
15071507
std::set<uint256> GetMasternodeQuorums(Consensus::LLMQType llmqType) const;
15081508
// also returns QWATCH nodes
1509-
std::set<NodeId> GetMasternodeQuorumNodes(Consensus::LLMQType llmqType, const uint256& quorumHash) const;
1509+
std::set<NodeId> GetMasternodeQuorumNodes(Consensus::LLMQType llmqType, const uint256& quorumHash) const EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex);
15101510
void RemoveMasternodeQuorumNodes(Consensus::LLMQType llmqType, const uint256& quorumHash);
15111511
bool IsMasternodeQuorumNode(const CNode* pnode, const CDeterministicMNList& tip_mn_list) const;
15121512
bool IsMasternodeQuorumRelayMember(const uint256& protxHash);
15131513
void AddPendingProbeConnections(const std::set<uint256>& proTxHashes);
15141514

1515-
size_t GetNodeCount(ConnectionDirection) const;
1515+
size_t GetNodeCount(ConnectionDirection) const EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex);
15161516
size_t GetMaxOutboundNodeCount();
15171517
size_t GetMaxOutboundOnionNodeCount();
1518-
void GetNodeStats(std::vector<CNodeStats>& vstats) const;
1519-
bool DisconnectNode(const std::string& node);
1520-
bool DisconnectNode(const CSubNet& subnet);
1521-
bool DisconnectNode(const CNetAddr& addr);
1522-
bool DisconnectNode(NodeId id);
1518+
void GetNodeStats(std::vector<CNodeStats>& vstats) const EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex);
1519+
bool DisconnectNode(const std::string& node) EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex);
1520+
bool DisconnectNode(const CSubNet& subnet) EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex);
1521+
bool DisconnectNode(const CNetAddr& addr) EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex);
1522+
bool DisconnectNode(NodeId id) EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex);
15231523

15241524
//! Used to convey which local services we are offering peers during node
15251525
//! connection.
@@ -1564,7 +1564,7 @@ friend class CNode;
15641564
{
15651565
public:
15661566
explicit NodesSnapshot(const CConnman& connman, std::function<bool(const CNode* pnode)> cond = AllNodes,
1567-
bool shuffle = false);
1567+
bool shuffle = false) EXCLUSIVE_LOCKS_REQUIRED(!connman.m_nodes_mutex);
15681568
~NodesSnapshot();
15691569

15701570
const std::vector<CNode*>& Nodes() const
@@ -1599,16 +1599,16 @@ friend class CNode;
15991599
bool InitBinds(const Options& options);
16001600

16011601
void ThreadOpenAddedConnections()
1602-
EXCLUSIVE_LOCKS_REQUIRED(!m_added_nodes_mutex, !m_unused_i2p_sessions_mutex, !m_reconnections_mutex, !mutexMsgProc);
1602+
EXCLUSIVE_LOCKS_REQUIRED(!m_added_nodes_mutex, !m_unused_i2p_sessions_mutex, !m_reconnections_mutex, !mutexMsgProc, !m_nodes_mutex);
16031603
void AddAddrFetch(const std::string& strDest) EXCLUSIVE_LOCKS_REQUIRED(!m_addr_fetches_mutex);
16041604
void ProcessAddrFetch()
1605-
EXCLUSIVE_LOCKS_REQUIRED(!m_addr_fetches_mutex, !m_unused_i2p_sessions_mutex, !mutexMsgProc);
1605+
EXCLUSIVE_LOCKS_REQUIRED(!m_addr_fetches_mutex, !m_unused_i2p_sessions_mutex, !mutexMsgProc, !m_nodes_mutex);
16061606
void ThreadOpenConnections(const std::vector<std::string> connect, CDeterministicMNManager& dmnman)
16071607
EXCLUSIVE_LOCKS_REQUIRED(!m_addr_fetches_mutex, !m_added_nodes_mutex, !m_nodes_mutex, !m_unused_i2p_sessions_mutex, !m_reconnections_mutex, !mutexMsgProc);
1608-
void ThreadMessageHandler() EXCLUSIVE_LOCKS_REQUIRED(!mutexMsgProc);
1609-
void ThreadI2PAcceptIncoming(CMasternodeSync& mn_sync) EXCLUSIVE_LOCKS_REQUIRED(!mutexMsgProc);
1608+
void ThreadMessageHandler() EXCLUSIVE_LOCKS_REQUIRED(!mutexMsgProc, !m_nodes_mutex);
1609+
void ThreadI2PAcceptIncoming(CMasternodeSync& mn_sync) EXCLUSIVE_LOCKS_REQUIRED(!mutexMsgProc, !m_nodes_mutex);
16101610
void AcceptConnection(const ListenSocket& hListenSocket, CMasternodeSync& mn_sync)
1611-
EXCLUSIVE_LOCKS_REQUIRED(!mutexMsgProc);
1611+
EXCLUSIVE_LOCKS_REQUIRED(!mutexMsgProc, !m_nodes_mutex);
16121612

16131613
/**
16141614
* Create a `CNode` object from a socket that has just been accepted and add the node to
@@ -1622,11 +1622,11 @@ friend class CNode;
16221622
NetPermissionFlags permission_flags,
16231623
const CAddress& addr_bind,
16241624
const CAddress& addr,
1625-
CMasternodeSync& mn_sync) EXCLUSIVE_LOCKS_REQUIRED(!mutexMsgProc);
1625+
CMasternodeSync& mn_sync) EXCLUSIVE_LOCKS_REQUIRED(!mutexMsgProc, !m_nodes_mutex);
16261626

16271627
void DisconnectNodes() EXCLUSIVE_LOCKS_REQUIRED(!m_reconnections_mutex, !m_nodes_mutex);
1628-
void NotifyNumConnectionsChanged(CMasternodeSync& mn_sync);
1629-
void CalculateNumConnectionsChangedStats();
1628+
void NotifyNumConnectionsChanged(CMasternodeSync& mn_sync) EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex);
1629+
void CalculateNumConnectionsChangedStats() EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex);
16301630
/** Return true if the peer is inactive and should be disconnected. */
16311631
bool InactivityCheck(const CNode& node) const;
16321632

@@ -1686,7 +1686,7 @@ friend class CNode;
16861686
/**
16871687
* Check connected and listening sockets for IO readiness and process them accordingly.
16881688
*/
1689-
void SocketHandler(CMasternodeSync& mn_sync) EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex, !mutexMsgProc);
1689+
void SocketHandler(CMasternodeSync& mn_sync) EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex, !mutexMsgProc, !m_nodes_mutex);
16901690

16911691
/**
16921692
* Do the read/write for connected sockets that are ready for IO.
@@ -1697,14 +1697,14 @@ friend class CNode;
16971697
void SocketHandlerConnected(const std::set<SOCKET>& recv_set,
16981698
const std::set<SOCKET>& send_set,
16991699
const std::set<SOCKET>& error_set)
1700-
EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex, !mutexMsgProc);
1700+
EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex, !mutexMsgProc, !m_nodes_mutex);
17011701

17021702
/**
17031703
* Accept incoming connections, one from each read-ready listening socket.
17041704
* @param[in] recv_set Sockets that are ready for read.
17051705
*/
17061706
void SocketHandlerListening(const std::set<SOCKET>& recv_set, CMasternodeSync& mn_sync)
1707-
EXCLUSIVE_LOCKS_REQUIRED(!mutexMsgProc);
1707+
EXCLUSIVE_LOCKS_REQUIRED(!mutexMsgProc, !m_nodes_mutex);
17081708

17091709
void ThreadSocketHandler(CMasternodeSync& mn_sync)
17101710
EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex, !mutexMsgProc, !m_nodes_mutex, !m_reconnections_mutex);
@@ -1715,19 +1715,19 @@ friend class CNode;
17151715

17161716
uint64_t CalculateKeyedNetGroup(const CAddress& ad) const;
17171717

1718-
CNode* FindNode(const CNetAddr& ip, bool fExcludeDisconnecting = true);
1719-
CNode* FindNode(const CSubNet& subNet, bool fExcludeDisconnecting = true);
1720-
CNode* FindNode(const std::string& addrName, bool fExcludeDisconnecting = true);
1721-
CNode* FindNode(const CService& addr, bool fExcludeDisconnecting = true);
1718+
CNode* FindNode(const CNetAddr& ip, bool fExcludeDisconnecting = true) EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex);
1719+
CNode* FindNode(const CSubNet& subNet, bool fExcludeDisconnecting = true) EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex);
1720+
CNode* FindNode(const std::string& addrName, bool fExcludeDisconnecting = true) EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex);
1721+
CNode* FindNode(const CService& addr, bool fExcludeDisconnecting = true) EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex);
17221722

17231723
/**
17241724
* Determine whether we're already connected to a given address, in order to
17251725
* avoid initiating duplicate connections.
17261726
*/
1727-
bool AlreadyConnectedToAddress(const CAddress& addr);
1727+
bool AlreadyConnectedToAddress(const CAddress& addr) EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex);
17281728

1729-
bool AttemptToEvictConnection();
1730-
CNode* ConnectNode(CAddress addrConnect, const char *pszDest, bool fCountFailure, ConnectionType conn_type, bool use_v2transport) EXCLUSIVE_LOCKS_REQUIRED(!m_unused_i2p_sessions_mutex);
1729+
bool AttemptToEvictConnection() EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex);
1730+
CNode* ConnectNode(CAddress addrConnect, const char *pszDest, bool fCountFailure, ConnectionType conn_type, bool use_v2transport) EXCLUSIVE_LOCKS_REQUIRED(!m_unused_i2p_sessions_mutex, !m_nodes_mutex);
17311731
void AddWhitelistPermissionFlags(NetPermissionFlags& flags, const CNetAddr &addr) const;
17321732

17331733
void DeleteNode(CNode* pnode);
@@ -1737,7 +1737,7 @@ friend class CNode;
17371737
/** (Try to) send data from node's vSendMsg. Returns (bytes_sent, data_left). */
17381738
std::pair<size_t, bool> SocketSendData(CNode& node) const EXCLUSIVE_LOCKS_REQUIRED(node.cs_vSend);
17391739

1740-
size_t SocketRecvData(CNode* pnode) EXCLUSIVE_LOCKS_REQUIRED(!mutexMsgProc);
1740+
size_t SocketRecvData(CNode* pnode) EXCLUSIVE_LOCKS_REQUIRED(!mutexMsgProc, !m_nodes_mutex);
17411741

17421742
void DumpAddresses();
17431743

@@ -1754,7 +1754,7 @@ friend class CNode;
17541754
/**
17551755
* Return vector of current BLOCK_RELAY peers.
17561756
*/
1757-
std::vector<CAddress> GetCurrentBlockRelayOnlyConns() const;
1757+
std::vector<CAddress> GetCurrentBlockRelayOnlyConns() const EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex);
17581758

17591759
/**
17601760
* Search for a "preferred" network, a reachable network to which we
@@ -1766,7 +1766,7 @@ friend class CNode;
17661766
*
17671767
* @return bool Whether a preferred network was found.
17681768
*/
1769-
bool MaybePickPreferredNetwork(std::optional<Network>& network);
1769+
bool MaybePickPreferredNetwork(std::optional<Network>& network) EXCLUSIVE_LOCKS_REQUIRED(!m_nodes_mutex);
17701770

17711771
// Whether the node should be passed out in ForEach* callbacks
17721772
static bool NodeFullyConnected(const CNode* pnode);
@@ -1806,7 +1806,7 @@ friend class CNode;
18061806
mutable Mutex m_added_nodes_mutex;
18071807
std::vector<CNode*> m_nodes GUARDED_BY(m_nodes_mutex);
18081808
std::list<CNode*> m_nodes_disconnected;
1809-
mutable RecursiveMutex m_nodes_mutex;
1809+
mutable Mutex m_nodes_mutex;
18101810
std::atomic<NodeId> nLastNodeId{0};
18111811
unsigned int nPrevNodeCount{0};
18121812

@@ -1993,7 +1993,7 @@ friend class CNode;
19931993
std::list<ReconnectionInfo> m_reconnections GUARDED_BY(m_reconnections_mutex);
19941994

19951995
/** Attempt reconnections, if m_reconnections non-empty. */
1996-
void PerformReconnections() EXCLUSIVE_LOCKS_REQUIRED(!mutexMsgProc, !m_reconnections_mutex, !m_unused_i2p_sessions_mutex);
1996+
void PerformReconnections() EXCLUSIVE_LOCKS_REQUIRED(!mutexMsgProc, !m_reconnections_mutex, !m_unused_i2p_sessions_mutex, !m_nodes_mutex);
19971997

19981998
/**
19991999
* Cap on the size of `m_unused_i2p_sessions`, to ensure it does not

0 commit comments

Comments
 (0)