diff options
author | Matt Corallo <matt@bluematt.me> | 2011-11-21 12:25:00 -0500 |
---|---|---|
committer | Matt Corallo <matt@bluematt.me> | 2011-11-26 14:28:46 -0500 |
commit | 2bc6cecebba52e32db43a0b2d9b519ac4a48c479 (patch) | |
tree | 4512b4adb3dd1796f4129c7afe3d15c52a52bb39 /src | |
parent | 50aa850fc8e16dd90577f85477dae40bfa4abb27 (diff) |
Move DNS Seed lookup to a new thread.
Diffstat (limited to 'src')
-rw-r--r-- | src/init.cpp | 5 | ||||
-rw-r--r-- | src/net.cpp | 39 | ||||
-rw-r--r-- | src/net.h | 1 |
3 files changed, 38 insertions, 7 deletions
diff --git a/src/init.cpp b/src/init.cpp index a6d0ab56e3..ee31ff9485 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -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)) diff --git a/src/net.cpp b/src/net.cpp index 0c28eaa379..199fb407f2 100644 --- a/src/net.cpp +++ b/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(); |