diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2012-02-15 21:17:15 +0100 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2012-02-15 21:17:15 +0100 |
commit | cc201e01f8216b2a95c9825b31530df9beb0f32b (patch) | |
tree | e5a04b7ee69937c14acef350ed255abb4caa2c02 /src/net.cpp | |
parent | c85c37acb16df6c8911c81689932890eec6864a3 (diff) |
Several shutdown-related fixes
* do not let vnThreadsRunning[1] go negative
* do not perform locking operations while vnThreadsRunning[1] is decreased
* check vnThreadsRunning[1] at exit
Diffstat (limited to 'src/net.cpp')
-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 63829d0e0a..92afdb0dc7 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1274,9 +1274,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; @@ -1288,13 +1292,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; @@ -1766,7 +1769,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 ) { |