diff options
author | Matt Corallo <git@bluematt.me> | 2017-01-24 16:51:22 -0500 |
---|---|---|
committer | Matt Corallo <git@bluematt.me> | 2017-01-25 18:59:16 -0500 |
commit | 236618061a445d2cb11e722cfac5fdae5be26abb (patch) | |
tree | 274900c35be308f40059881f196fcdc35cb02132 /src/net.cpp | |
parent | 3c37dc40d39e1a1e56b6b0d3e660626a78656d4f (diff) |
Do not add to vNodes until fOneShot/fFeeler/fAddNode have been set
Diffstat (limited to 'src/net.cpp')
-rw-r--r-- | src/net.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/net.cpp b/src/net.cpp index 7489b3f32b..108d95a176 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -342,8 +342,8 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo CNode* pnode = FindNode((CService)addrConnect); if (pnode) { - pnode->AddRef(); - return pnode; + LogPrintf("Failed to open new connection, already connected\n"); + return NULL; } } @@ -373,12 +373,12 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo CNode* pnode = FindNode((CService)addrConnect); if (pnode) { - pnode->AddRef(); if (pnode->addrName.empty()) { pnode->addrName = std::string(pszDest); } CloseSocket(hSocket); - return pnode; + LogPrintf("Failed to open new connection, already connected\n"); + return NULL; } } @@ -391,11 +391,6 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo pnode->nServicesExpected = ServiceFlags(addrConnect.nServices & nRelevantServices); pnode->nTimeConnected = GetTime(); pnode->AddRef(); - GetNodeSignals().InitializeNode(pnode, *this); - { - LOCK(cs_vNodes); - vNodes.push_back(pnode); - } return pnode; } else if (!proxyConnectionFailed) { @@ -1838,6 +1833,12 @@ bool CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFai if (fAddnode) pnode->fAddnode = true; + { + LOCK(cs_vNodes); + vNodes.push_back(pnode); + } + GetNodeSignals().InitializeNode(pnode, *this); + return true; } |