diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2012-02-16 03:34:11 -0800 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2012-02-16 03:34:11 -0800 |
commit | 999b4cacaf53189dc9e8d5c6373c1f3da5b8ae4c (patch) | |
tree | 4bc287cfb25ea68dd30693cbe2833ac10940dd42 /src | |
parent | 2030fc6bc2df90a30e1949cc6fbcfd75e420f5f9 (diff) | |
parent | cc201e01f8216b2a95c9825b31530df9beb0f32b (diff) |
Merge pull request #844 from sipa/shutdownfix
Several shutdown-related fixes
Diffstat (limited to 'src')
-rw-r--r-- | src/net.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/net.cpp b/src/net.cpp index a66b1a61d8..3a1777f3f2 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1278,9 +1278,13 @@ void ThreadOpenConnections2(void* parg) int64 nStart = GetTime(); loop { - // Limit outbound connections vnThreadsRunning[1]--; Sleep(500); + vnThreadsRunning[1]++; + if (fShutdown) + return; + + // Limit outbound connections loop { int nOutbound = 0; @@ -1292,13 +1296,12 @@ void ThreadOpenConnections2(void* parg) nMaxOutboundConnections = min(nMaxOutboundConnections, (int)GetArg("-maxconnections", 125)); if (nOutbound < nMaxOutboundConnections) break; + vnThreadsRunning[1]--; Sleep(2000); + vnThreadsRunning[1]++; if (fShutdown) return; } - vnThreadsRunning[1]++; - if (fShutdown) - return; bool fAddSeeds = false; @@ -1770,7 +1773,7 @@ bool StopNode() fShutdown = true; nTransactionsUpdated++; int64 nStart = GetTime(); - while (vnThreadsRunning[0] > 0 || vnThreadsRunning[2] > 0 || vnThreadsRunning[3] > 0 || vnThreadsRunning[4] > 0 + while (vnThreadsRunning[0] > 0 || vnThreadsRunning[1] > 0 || vnThreadsRunning[2] > 0 || vnThreadsRunning[3] > 0 || vnThreadsRunning[4] > 0 || (fHaveUPnP && vnThreadsRunning[5] > 0) || vnThreadsRunning[6] > 0 || vnThreadsRunning[7] > 0 ) { |