Partially backport Bitcoin PR#9626: Clean up a few CConnman cs_vNodes/CNode things (#1591)
* Delete some unused (and broken) functions in CConnman * Ensure cs_vNodes is held when using the return value from FindNode
This commit is contained in:
parent
4f5455000e
commit
105122181a
27
src/net.cpp
27
src/net.cpp
@ -388,6 +388,7 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
|
|||||||
// In that case, drop the connection that was just created, and return the existing CNode instead.
|
// In that case, drop the connection that was just created, and return the existing CNode instead.
|
||||||
// Also store the name we used to connect in that CNode, so that future FindNode() calls to that
|
// Also store the name we used to connect in that CNode, so that future FindNode() calls to that
|
||||||
// name catch this early.
|
// name catch this early.
|
||||||
|
LOCK(cs_vNodes);
|
||||||
CNode* pnode = FindNode((CService)addrConnect);
|
CNode* pnode = FindNode((CService)addrConnect);
|
||||||
if (pnode)
|
if (pnode)
|
||||||
{
|
{
|
||||||
@ -397,11 +398,8 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
|
|||||||
pnode->AddRef();
|
pnode->AddRef();
|
||||||
pnode->fMasternode = true;
|
pnode->fMasternode = true;
|
||||||
}
|
}
|
||||||
{
|
if (pnode->addrName.empty()) {
|
||||||
LOCK(cs_vNodes);
|
pnode->addrName = std::string(pszDest);
|
||||||
if (pnode->addrName.empty()) {
|
|
||||||
pnode->addrName = std::string(pszDest);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
CloseSocket(hSocket);
|
CloseSocket(hSocket);
|
||||||
return pnode;
|
return pnode;
|
||||||
@ -2400,26 +2398,9 @@ void CConnman::GetNodeStats(std::vector<CNodeStats>& vstats)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CConnman::DisconnectAddress(const CNetAddr& netAddr)
|
|
||||||
{
|
|
||||||
if (CNode* pnode = FindNode(netAddr)) {
|
|
||||||
pnode->fDisconnect = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CConnman::DisconnectSubnet(const CSubNet& subNet)
|
|
||||||
{
|
|
||||||
if (CNode* pnode = FindNode(subNet)) {
|
|
||||||
pnode->fDisconnect = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CConnman::DisconnectNode(const std::string& strNode)
|
bool CConnman::DisconnectNode(const std::string& strNode)
|
||||||
{
|
{
|
||||||
|
LOCK(cs_vNodes);
|
||||||
if (CNode* pnode = FindNode(strNode)) {
|
if (CNode* pnode = FindNode(strNode)) {
|
||||||
pnode->fDisconnect = true;
|
pnode->fDisconnect = true;
|
||||||
return true;
|
return true;
|
||||||
|
@ -347,10 +347,8 @@ public:
|
|||||||
|
|
||||||
size_t GetNodeCount(NumConnections num);
|
size_t GetNodeCount(NumConnections num);
|
||||||
void GetNodeStats(std::vector<CNodeStats>& vstats);
|
void GetNodeStats(std::vector<CNodeStats>& vstats);
|
||||||
bool DisconnectAddress(const CNetAddr& addr);
|
|
||||||
bool DisconnectNode(const std::string& node);
|
bool DisconnectNode(const std::string& node);
|
||||||
bool DisconnectNode(NodeId id);
|
bool DisconnectNode(NodeId id);
|
||||||
bool DisconnectSubnet(const CSubNet& subnet);
|
|
||||||
|
|
||||||
unsigned int GetSendBufferSize() const;
|
unsigned int GetSendBufferSize() const;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user