Move DNS Seed lookup to a new thread.
This commit is contained in:
parent
50aa850fc8
commit
2bc6cecebb
@ -476,11 +476,6 @@ bool AppInit2(int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (GetBoolArg("-nodnsseed"))
|
||||
printf("DNS seeding disabled\n");
|
||||
else
|
||||
DNSAddressSeed();
|
||||
|
||||
if (mapArgs.count("-paytxfee"))
|
||||
{
|
||||
if (!ParseMoney(mapArgs["-paytxfee"], nTransactionFee))
|
||||
|
39
src/net.cpp
39
src/net.cpp
@ -32,6 +32,7 @@ void ThreadOpenConnections2(void* parg);
|
||||
#ifdef USE_UPNP
|
||||
void ThreadMapPort2(void* parg);
|
||||
#endif
|
||||
void ThreadDNSAddressSeed2(void* parg);
|
||||
bool OpenNetworkConnection(const CAddress& addrConnect);
|
||||
|
||||
|
||||
@ -1213,8 +1214,28 @@ static const char *strDNSSeed[] = {
|
||||
"dnsseed.bluematt.me",
|
||||
};
|
||||
|
||||
void DNSAddressSeed()
|
||||
void ThreadDNSAddressSeed(void* parg)
|
||||
{
|
||||
IMPLEMENT_RANDOMIZE_STACK(ThreadDNSAddressSeed(parg));
|
||||
try
|
||||
{
|
||||
vnThreadsRunning[6]++;
|
||||
ThreadDNSAddressSeed2(parg);
|
||||
vnThreadsRunning[6]--;
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
vnThreadsRunning[6]--;
|
||||
PrintException(&e, "ThreadDNSAddressSeed()");
|
||||
} catch (...) {
|
||||
vnThreadsRunning[6]--;
|
||||
throw; // support pthread_cancel()
|
||||
}
|
||||
printf("ThreadDNSAddressSeed exiting\n");
|
||||
}
|
||||
|
||||
void ThreadDNSAddressSeed2(void* parg)
|
||||
{
|
||||
printf("ThreadDNSAddressSeed started\n");
|
||||
int found = 0;
|
||||
|
||||
if (!fTestNet)
|
||||
@ -1247,6 +1268,15 @@ void DNSAddressSeed()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
unsigned int pnSeed[] =
|
||||
{
|
||||
0x6884ac63, 0x3ffecead, 0x2919b953, 0x0942fe50, 0x7a1d922e, 0xcdd6734a, 0x953a5bb6, 0x2c46922e,
|
||||
@ -1757,6 +1787,12 @@ void StartNode(void* parg)
|
||||
// Start threads
|
||||
//
|
||||
|
||||
if (GetBoolArg("-nodnsseed"))
|
||||
printf("DNS seeding disabled\n");
|
||||
else
|
||||
if (!CreateThread(ThreadDNSAddressSeed, NULL))
|
||||
printf("Error: CreateThread(ThreadDNSAddressSeed) failed\n");
|
||||
|
||||
// Map ports with UPnP
|
||||
if (fHaveUPnP)
|
||||
MapPort(fUseUPnP);
|
||||
@ -1803,6 +1839,7 @@ bool StopNode()
|
||||
if (vnThreadsRunning[3] > 0) printf("ThreadBitcoinMiner still running\n");
|
||||
if (vnThreadsRunning[4] > 0) printf("ThreadRPCServer still running\n");
|
||||
if (fHaveUPnP && vnThreadsRunning[5] > 0) printf("ThreadMapPort still running\n");
|
||||
if (vnThreadsRunning[6] > 0) printf("ThreadDNSAddressSeed still running\n");
|
||||
while (vnThreadsRunning[2] > 0 || vnThreadsRunning[4] > 0)
|
||||
Sleep(20);
|
||||
Sleep(50);
|
||||
|
@ -40,7 +40,6 @@ CNode* ConnectNode(CAddress addrConnect, int64 nTimeout=0);
|
||||
void AbandonRequests(void (*fn)(void*, CDataStream&), void* param1);
|
||||
bool AnySubscribed(unsigned int nChannel);
|
||||
void MapPort(bool fMapPort);
|
||||
void DNSAddressSeed();
|
||||
bool BindListenPort(std::string& strError=REF(std::string()));
|
||||
void StartNode(void* parg);
|
||||
bool StopNode();
|
||||
|
Loading…
Reference in New Issue
Block a user