Browse Source

Merge pull request #844 from sipa/shutdownfix

Several shutdown-related fixes
miguelfreitas
Pieter Wuille 13 years ago
parent
commit
999b4cacaf
  1. 13
      src/net.cpp

13
src/net.cpp

@ -1278,9 +1278,13 @@ void ThreadOpenConnections2(void* parg)
int64 nStart = GetTime(); int64 nStart = GetTime();
loop loop
{ {
// Limit outbound connections
vnThreadsRunning[1]--; vnThreadsRunning[1]--;
Sleep(500); Sleep(500);
vnThreadsRunning[1]++;
if (fShutdown)
return;
// Limit outbound connections
loop loop
{ {
int nOutbound = 0; int nOutbound = 0;
@ -1292,13 +1296,12 @@ void ThreadOpenConnections2(void* parg)
nMaxOutboundConnections = min(nMaxOutboundConnections, (int)GetArg("-maxconnections", 125)); nMaxOutboundConnections = min(nMaxOutboundConnections, (int)GetArg("-maxconnections", 125));
if (nOutbound < nMaxOutboundConnections) if (nOutbound < nMaxOutboundConnections)
break; break;
vnThreadsRunning[1]--;
Sleep(2000); Sleep(2000);
if (fShutdown)
return;
}
vnThreadsRunning[1]++; vnThreadsRunning[1]++;
if (fShutdown) if (fShutdown)
return; return;
}
bool fAddSeeds = false; bool fAddSeeds = false;
@ -1770,7 +1773,7 @@ bool StopNode()
fShutdown = true; fShutdown = true;
nTransactionsUpdated++; nTransactionsUpdated++;
int64 nStart = GetTime(); 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 || (fHaveUPnP && vnThreadsRunning[5] > 0) || vnThreadsRunning[6] > 0 || vnThreadsRunning[7] > 0
) )
{ {

Loading…
Cancel
Save