diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/net.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/net.cpp b/src/net.cpp index b9597d92b9..b314405efc 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -931,13 +931,17 @@ void ThreadSocketHandler2(void* parg) struct sockaddr_in sockaddr; socklen_t len = sizeof(sockaddr); SOCKET hSocket = accept(hListenSocket, (struct sockaddr*)&sockaddr, &len); - CAddress addr(sockaddr); + CAddress addr; int nInbound = 0; + if (hSocket != INVALID_SOCKET) + addr = CAddress(sockaddr); + CRITICAL_BLOCK(cs_vNodes) BOOST_FOREACH(CNode* pnode, vNodes) if (pnode->fInbound) nInbound++; + if (hSocket == INVALID_SOCKET) { if (WSAGetLastError() != WSAEWOULDBLOCK) @@ -1478,9 +1482,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; @@ -1492,13 +1500,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; @@ -1895,7 +1902,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 #ifdef USE_UPNP || vnThreadsRunning[5] > 0 #endif |