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.
|
||||
// Also store the name we used to connect in that CNode, so that future FindNode() calls to that
|
||||
// name catch this early.
|
||||
LOCK(cs_vNodes);
|
||||
CNode* pnode = FindNode((CService)addrConnect);
|
||||
if (pnode)
|
||||
{
|
||||
@ -397,11 +398,8 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
|
||||
pnode->AddRef();
|
||||
pnode->fMasternode = true;
|
||||
}
|
||||
{
|
||||
LOCK(cs_vNodes);
|
||||
if (pnode->addrName.empty()) {
|
||||
pnode->addrName = std::string(pszDest);
|
||||
}
|
||||
if (pnode->addrName.empty()) {
|
||||
pnode->addrName = std::string(pszDest);
|
||||
}
|
||||
CloseSocket(hSocket);
|
||||
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)
|
||||
{
|
||||
LOCK(cs_vNodes);
|
||||
if (CNode* pnode = FindNode(strNode)) {
|
||||
pnode->fDisconnect = true;
|
||||
return true;
|
||||
|
@ -347,10 +347,8 @@ public:
|
||||
|
||||
size_t GetNodeCount(NumConnections num);
|
||||
void GetNodeStats(std::vector<CNodeStats>& vstats);
|
||||
bool DisconnectAddress(const CNetAddr& addr);
|
||||
bool DisconnectNode(const std::string& node);
|
||||
bool DisconnectNode(NodeId id);
|
||||
bool DisconnectSubnet(const CSubNet& subnet);
|
||||
|
||||
unsigned int GetSendBufferSize() const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user