aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2011-12-02 07:09:41 -0800
committerGavin Andresen <gavinandresen@gmail.com>2011-12-02 07:09:41 -0800
commit43ae68b5efb2d7f8c23f64d3efdbd49c9d90aff2 (patch)
tree186c1a741e48c5d397af28874325ef9ddfc2d8e4 /src
parent173efb1865e271dede53bcdff7ee2e189df07aa4 (diff)
parent2bc6cecebba52e32db43a0b2d9b519ac4a48c479 (diff)
Merge pull request #654 from TheBlueMatt/dnsseed-thread
Move DNS Seed lookup to a new thread.
Diffstat (limited to 'src')
-rw-r--r--src/init.cpp5
-rw-r--r--src/net.cpp39
-rw-r--r--src/net.h1
3 files changed, 38 insertions, 7 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 367e75f39b..dd8bdf5598 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -487,11 +487,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);
diff --git a/src/net.h b/src/net.h
index d847268999..03da382df3 100644
--- a/src/net.h
+++ b/src/net.h
@@ -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();