|
|
@ -72,6 +72,9 @@ CCriticalSection cs_vOneShots; |
|
|
|
set<CNetAddr> setservAddNodeAddresses; |
|
|
|
set<CNetAddr> setservAddNodeAddresses; |
|
|
|
CCriticalSection cs_setservAddNodeAddresses; |
|
|
|
CCriticalSection cs_setservAddNodeAddresses; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vector<std::string> vAddedNodes; |
|
|
|
|
|
|
|
CCriticalSection cs_vAddedNodes; |
|
|
|
|
|
|
|
|
|
|
|
static CSemaphore *semOutbound = NULL; |
|
|
|
static CSemaphore *semOutbound = NULL; |
|
|
|
|
|
|
|
|
|
|
|
void AddOneShot(string strDest) |
|
|
|
void AddOneShot(string strDest) |
|
|
@ -1523,12 +1526,20 @@ void ThreadOpenAddedConnections2(void* parg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
printf("ThreadOpenAddedConnections started\n"); |
|
|
|
printf("ThreadOpenAddedConnections started\n"); |
|
|
|
|
|
|
|
|
|
|
|
if (mapArgs.count("-addnode") == 0) |
|
|
|
{ |
|
|
|
return; |
|
|
|
LOCK(cs_vAddedNodes); |
|
|
|
|
|
|
|
vAddedNodes = mapMultiArgs["-addnode"]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (HaveNameProxy()) { |
|
|
|
if (HaveNameProxy()) { |
|
|
|
while(!fShutdown) { |
|
|
|
while(!fShutdown) { |
|
|
|
BOOST_FOREACH(string& strAddNode, mapMultiArgs["-addnode"]) { |
|
|
|
list<string> lAddresses(0); |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
LOCK(cs_vAddedNodes); |
|
|
|
|
|
|
|
BOOST_FOREACH(string& strAddNode, vAddedNodes) |
|
|
|
|
|
|
|
lAddresses.push_back(strAddNode); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
BOOST_FOREACH(string& strAddNode, lAddresses) { |
|
|
|
CAddress addr; |
|
|
|
CAddress addr; |
|
|
|
CSemaphoreGrant grant(*semOutbound); |
|
|
|
CSemaphoreGrant grant(*semOutbound); |
|
|
|
OpenNetworkConnection(addr, &grant, strAddNode.c_str()); |
|
|
|
OpenNetworkConnection(addr, &grant, strAddNode.c_str()); |
|
|
@ -1541,38 +1552,44 @@ void ThreadOpenAddedConnections2(void* parg) |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
vector<vector<CService> > vservAddressesToAdd(0); |
|
|
|
loop |
|
|
|
BOOST_FOREACH(string& strAddNode, mapMultiArgs["-addnode"]) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
vector<CService> vservNode(0); |
|
|
|
list<string> lAddresses(0); |
|
|
|
if(Lookup(strAddNode.c_str(), vservNode, GetDefaultPort(), fNameLookup, 0)) |
|
|
|
{ |
|
|
|
|
|
|
|
LOCK(cs_vAddedNodes); |
|
|
|
|
|
|
|
BOOST_FOREACH(string& strAddNode, vAddedNodes) |
|
|
|
|
|
|
|
lAddresses.push_back(strAddNode); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
list<vector<CService> > lservAddressesToAdd(0); |
|
|
|
|
|
|
|
BOOST_FOREACH(string& strAddNode, lAddresses) |
|
|
|
{ |
|
|
|
{ |
|
|
|
vservAddressesToAdd.push_back(vservNode); |
|
|
|
vector<CService> vservNode(0); |
|
|
|
|
|
|
|
if(Lookup(strAddNode.c_str(), vservNode, GetDefaultPort(), fNameLookup, 0)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LOCK(cs_setservAddNodeAddresses); |
|
|
|
lservAddressesToAdd.push_back(vservNode); |
|
|
|
BOOST_FOREACH(CService& serv, vservNode) |
|
|
|
{ |
|
|
|
setservAddNodeAddresses.insert(serv); |
|
|
|
LOCK(cs_setservAddNodeAddresses); |
|
|
|
|
|
|
|
BOOST_FOREACH(CService& serv, vservNode) |
|
|
|
|
|
|
|
setservAddNodeAddresses.insert(serv); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
loop |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
vector<vector<CService> > vservConnectAddresses = vservAddressesToAdd; |
|
|
|
|
|
|
|
// Attempt to connect to each IP for each addnode entry until at least one is successful per addnode entry
|
|
|
|
// Attempt to connect to each IP for each addnode entry until at least one is successful per addnode entry
|
|
|
|
// (keeping in mind that addnode entries can have many IPs if fNameLookup)
|
|
|
|
// (keeping in mind that addnode entries can have many IPs if fNameLookup)
|
|
|
|
{ |
|
|
|
{ |
|
|
|
LOCK(cs_vNodes); |
|
|
|
LOCK(cs_vNodes); |
|
|
|
BOOST_FOREACH(CNode* pnode, vNodes) |
|
|
|
BOOST_FOREACH(CNode* pnode, vNodes) |
|
|
|
for (vector<vector<CService> >::iterator it = vservConnectAddresses.begin(); it != vservConnectAddresses.end(); it++) |
|
|
|
for (list<vector<CService> >::iterator it = lservAddressesToAdd.begin(); it != lservAddressesToAdd.end(); it++) |
|
|
|
BOOST_FOREACH(CService& addrNode, *(it)) |
|
|
|
BOOST_FOREACH(CService& addrNode, *(it)) |
|
|
|
if (pnode->addr == addrNode) |
|
|
|
if (pnode->addr == addrNode) |
|
|
|
{ |
|
|
|
{ |
|
|
|
it = vservConnectAddresses.erase(it); |
|
|
|
it = lservAddressesToAdd.erase(it); |
|
|
|
it--; |
|
|
|
it--; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
BOOST_FOREACH(vector<CService>& vserv, vservConnectAddresses) |
|
|
|
BOOST_FOREACH(vector<CService>& vserv, lservAddressesToAdd) |
|
|
|
{ |
|
|
|
{ |
|
|
|
CSemaphoreGrant grant(*semOutbound); |
|
|
|
CSemaphoreGrant grant(*semOutbound); |
|
|
|
OpenNetworkConnection(CAddress(*(vserv.begin())), &grant); |
|
|
|
OpenNetworkConnection(CAddress(*(vserv.begin())), &grant); |
|
|
|