Browse Source

Do not add to vNodes until fOneShot/fFeeler/fAddNode have been set

0.14
Matt Corallo 8 years ago
parent
commit
236618061a
  1. 19
      src/net.cpp

19
src/net.cpp

@ -342,8 +342,8 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
CNode* pnode = FindNode((CService)addrConnect); CNode* pnode = FindNode((CService)addrConnect);
if (pnode) if (pnode)
{ {
pnode->AddRef(); LogPrintf("Failed to open new connection, already connected\n");
return pnode; return NULL;
} }
} }
@ -373,12 +373,12 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
CNode* pnode = FindNode((CService)addrConnect); CNode* pnode = FindNode((CService)addrConnect);
if (pnode) if (pnode)
{ {
pnode->AddRef();
if (pnode->addrName.empty()) { if (pnode->addrName.empty()) {
pnode->addrName = std::string(pszDest); pnode->addrName = std::string(pszDest);
} }
CloseSocket(hSocket); 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->nServicesExpected = ServiceFlags(addrConnect.nServices & nRelevantServices);
pnode->nTimeConnected = GetTime(); pnode->nTimeConnected = GetTime();
pnode->AddRef(); pnode->AddRef();
GetNodeSignals().InitializeNode(pnode, *this);
{
LOCK(cs_vNodes);
vNodes.push_back(pnode);
}
return pnode; return pnode;
} else if (!proxyConnectionFailed) { } else if (!proxyConnectionFailed) {
@ -1838,6 +1833,12 @@ bool CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFai
if (fAddnode) if (fAddnode)
pnode->fAddnode = true; pnode->fAddnode = true;
{
LOCK(cs_vNodes);
vNodes.push_back(pnode);
}
GetNodeSignals().InitializeNode(pnode, *this);
return true; return true;
} }

Loading…
Cancel
Save