|
|
@ -35,7 +35,7 @@ void ThreadOpenAddedConnections2(void* parg); |
|
|
|
void ThreadMapPort2(void* parg); |
|
|
|
void ThreadMapPort2(void* parg); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
void ThreadDNSAddressSeed2(void* parg); |
|
|
|
void ThreadDNSAddressSeed2(void* parg); |
|
|
|
bool OpenNetworkConnection(const CAddress& addrConnect, const char *strDest = NULL); |
|
|
|
bool OpenNetworkConnection(const CAddress& addrConnect, const char *strDest = NULL, bool fOneShot = false); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -59,6 +59,8 @@ deque<pair<int64, CInv> > vRelayExpiration; |
|
|
|
CCriticalSection cs_mapRelay; |
|
|
|
CCriticalSection cs_mapRelay; |
|
|
|
map<CInv, int64> mapAlreadyAskedFor; |
|
|
|
map<CInv, int64> mapAlreadyAskedFor; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static deque<string> vOneShots; |
|
|
|
|
|
|
|
CCriticalSection cs_vOneShots; |
|
|
|
|
|
|
|
|
|
|
|
set<CNetAddr> setservAddNodeAddresses; |
|
|
|
set<CNetAddr> setservAddNodeAddresses; |
|
|
|
CCriticalSection cs_setservAddNodeAddresses; |
|
|
|
CCriticalSection cs_setservAddNodeAddresses; |
|
|
@ -68,6 +70,12 @@ static int nOutbound = 0; |
|
|
|
static CConditionVariable condOutbound; |
|
|
|
static CConditionVariable condOutbound; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void AddOneShot(string strDest) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
LOCK(cs_vOneShots); |
|
|
|
|
|
|
|
vOneShots.push_back(strDest); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
unsigned short GetListenPort() |
|
|
|
unsigned short GetListenPort() |
|
|
|
{ |
|
|
|
{ |
|
|
|
return (unsigned short)(GetArg("-port", GetDefaultPort())); |
|
|
|
return (unsigned short)(GetArg("-port", GetDefaultPort())); |
|
|
@ -328,7 +336,7 @@ CNode* FindNode(const CService& addr) |
|
|
|
|
|
|
|
|
|
|
|
CNode* ConnectNode(CAddress addrConnect, const char *pszDest, int64 nTimeout) |
|
|
|
CNode* ConnectNode(CAddress addrConnect, const char *pszDest, int64 nTimeout) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (pszDest != NULL) { |
|
|
|
if (pszDest == NULL) { |
|
|
|
if ((CNetAddr)addrConnect == (CNetAddr)addrLocalHost) |
|
|
|
if ((CNetAddr)addrConnect == (CNetAddr)addrLocalHost) |
|
|
|
return NULL; |
|
|
|
return NULL; |
|
|
|
|
|
|
|
|
|
|
@ -1038,8 +1046,7 @@ void ThreadDNSAddressSeed2(void* parg) |
|
|
|
|
|
|
|
|
|
|
|
for (unsigned int seed_idx = 0; seed_idx < ARRAYLEN(strDNSSeed); seed_idx++) { |
|
|
|
for (unsigned int seed_idx = 0; seed_idx < ARRAYLEN(strDNSSeed); seed_idx++) { |
|
|
|
if (fProxyNameLookup) { |
|
|
|
if (fProxyNameLookup) { |
|
|
|
CAddress addr; |
|
|
|
AddOneShot(strDNSSeed[seed_idx][1]); |
|
|
|
OpenNetworkConnection(addr, strDNSSeed[seed_idx][1]); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
vector<CNetAddr> vaddr; |
|
|
|
vector<CNetAddr> vaddr; |
|
|
|
vector<CAddress> vAdd; |
|
|
|
vector<CAddress> vAdd; |
|
|
@ -1205,6 +1212,21 @@ void ThreadOpenConnections(void* parg) |
|
|
|
printf("ThreadOpenConnections exiting\n"); |
|
|
|
printf("ThreadOpenConnections exiting\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void static ProcessOneShot() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
string strDest; |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
LOCK(cs_vOneShots); |
|
|
|
|
|
|
|
if (vOneShots.empty()) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
strDest = vOneShots.front(); |
|
|
|
|
|
|
|
vOneShots.pop_front(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
CAddress addr; |
|
|
|
|
|
|
|
if (!OpenNetworkConnection(addr, strDest.c_str(), true)) |
|
|
|
|
|
|
|
AddOneShot(strDest); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ThreadOpenConnections2(void* parg) |
|
|
|
void ThreadOpenConnections2(void* parg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
printf("ThreadOpenConnections started\n"); |
|
|
|
printf("ThreadOpenConnections started\n"); |
|
|
@ -1214,9 +1236,10 @@ void ThreadOpenConnections2(void* parg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
for (int64 nLoop = 0;; nLoop++) |
|
|
|
for (int64 nLoop = 0;; nLoop++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
ProcessOneShot(); |
|
|
|
BOOST_FOREACH(string strAddr, mapMultiArgs["-connect"]) |
|
|
|
BOOST_FOREACH(string strAddr, mapMultiArgs["-connect"]) |
|
|
|
{ |
|
|
|
{ |
|
|
|
CAddress addr(CService("0.0.0.0:0")); |
|
|
|
CAddress addr; |
|
|
|
OpenNetworkConnection(addr, strAddr.c_str()); |
|
|
|
OpenNetworkConnection(addr, strAddr.c_str()); |
|
|
|
for (int i = 0; i < 10 && i < nLoop; i++) |
|
|
|
for (int i = 0; i < 10 && i < nLoop; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1232,6 +1255,8 @@ void ThreadOpenConnections2(void* parg) |
|
|
|
int64 nStart = GetTime(); |
|
|
|
int64 nStart = GetTime(); |
|
|
|
loop |
|
|
|
loop |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
ProcessOneShot(); |
|
|
|
|
|
|
|
|
|
|
|
vnThreadsRunning[THREAD_OPENCONNECTIONS]--; |
|
|
|
vnThreadsRunning[THREAD_OPENCONNECTIONS]--; |
|
|
|
Sleep(500); |
|
|
|
Sleep(500); |
|
|
|
vnThreadsRunning[THREAD_OPENCONNECTIONS]++; |
|
|
|
vnThreadsRunning[THREAD_OPENCONNECTIONS]++; |
|
|
@ -1403,7 +1428,7 @@ void ThreadOpenAddedConnections2(void* parg) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool OpenNetworkConnection(const CAddress& addrConnect, const char *strDest) |
|
|
|
bool OpenNetworkConnection(const CAddress& addrConnect, const char *strDest, bool fOneShot) |
|
|
|
{ |
|
|
|
{ |
|
|
|
//
|
|
|
|
//
|
|
|
|
// Initiate outbound network connection
|
|
|
|
// Initiate outbound network connection
|
|
|
@ -1426,6 +1451,8 @@ bool OpenNetworkConnection(const CAddress& addrConnect, const char *strDest) |
|
|
|
if (!pnode) |
|
|
|
if (!pnode) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
pnode->fNetworkNode = true; |
|
|
|
pnode->fNetworkNode = true; |
|
|
|
|
|
|
|
if (fOneShot) |
|
|
|
|
|
|
|
pnode->fOneShot = true; |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|