|
|
@ -369,15 +369,13 @@ 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) |
|
|
|
{ |
|
|
|
{ |
|
|
|
pnode->AddRef(); |
|
|
|
pnode->AddRef(); |
|
|
|
{ |
|
|
|
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; |
|
|
@ -2373,6 +2371,7 @@ void CConnman::GetNodeStats(std::vector<CNodeStats>& vstats) |
|
|
|
|
|
|
|
|
|
|
|
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; |
|
|
|