mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-02 01:40:12 +02:00
Merge bitcoin/bitcoin#32326: net: improve the interface around FindNode() and avoid a recursive mutex lock
87e7f37918doc: clarify peer address in getpeerinfo and addnode RPC help (Vasil Dimov)2a4450ccbbnet: change FindNode() to not return a node and rename it (Vasil Dimov)4268abae1anet: avoid recursive m_nodes_mutex lock in DisconnectNode() (Vasil Dimov)3a4d1a25cfnet: merge AlreadyConnectedToAddress() and FindNode(CNetAddr) (Vasil Dimov) Pull request description: `CConnman::FindNode()` would lock `m_nodes_mutex`, find the node in `m_nodes`, release the mutex and return the node. The current code is safe but it is a dangerous interface where a caller may end up using the node returned from `FindNode()` without owning `m_nodes_mutex` and without having that node's reference count incremented. Change `FindNode()` to return a boolean since all but one of its callers used its return value to check whether a node exists and did not do anything else with the return value. Remove a recursive lock on `m_nodes_mutex`. Rename `FindNode()` to better describe what it does. ACKs for top commit: achow101: ACK87e7f37918furszy: Code review ACK87e7f37918hodlinator: re-ACK87e7f37918Tree-SHA512: 44fb64cd1226eca124ed1f447b4a1ebc42cc5c9e8561fc91949bbeaeaa7fa16fcfd664e85ce142e5abe62cb64197c178ca4ca93b3b3217b913e3c498d0b7d1c9
This commit is contained in:
@@ -107,7 +107,7 @@ struct ConnmanTestMsg : public CConnman {
|
||||
bool ReceiveMsgFrom(CNode& node, CSerializedNetMsg&& ser_msg) const;
|
||||
void FlushSendBuffer(CNode& node) const;
|
||||
|
||||
bool AlreadyConnectedPublic(const CAddress& addr) { return AlreadyConnectedToAddress(addr); };
|
||||
bool AlreadyConnectedToAddressPublic(const CNetAddr& addr) { return AlreadyConnectedToAddress(addr); };
|
||||
|
||||
CNode* ConnectNodePublic(PeerManager& peerman, const char* pszDest, ConnectionType conn_type)
|
||||
EXCLUSIVE_LOCKS_REQUIRED(!m_unused_i2p_sessions_mutex);
|
||||
|
||||
Reference in New Issue
Block a user