diff options
author | Gavin Andresen <gavinandresen@gmail.com> | 2013-03-07 14:25:21 -0500 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2013-04-03 14:04:21 -0400 |
commit | 1b43bf0d3ae7b1fcde0c0e20c23c341540f4c8d2 (patch) | |
tree | ca5ce1b1cfaa0ac8bf6d6eb069a985fe685135e6 /src/net.cpp | |
parent | c8c2fbe07f1a5475aea3a2680af9130558c7e5c8 (diff) |
Rename util.h Sleep --> MilliSleep
Two reasons for this change:
1. Need to always use boost::thread's sleep, even on Windows, so the
sleeps can be interrupted (prior code used Windows' built-in Sleep).
2. I always forgot what units the old Sleep took.
Diffstat (limited to 'src/net.cpp')
-rw-r--r-- | src/net.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/net.cpp b/src/net.cpp index 097f480b85..fe0dcd41b3 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -165,7 +165,7 @@ bool RecvLine(SOCKET hSocket, string& strLine) continue; if (nErr == WSAEWOULDBLOCK || nErr == WSAEINTR || nErr == WSAEINPROGRESS) { - Sleep(10); + MilliSleep(10); continue; } } @@ -909,7 +909,7 @@ void ThreadSocketHandler2(void* parg) } FD_ZERO(&fdsetSend); FD_ZERO(&fdsetError); - Sleep(timeout.tv_usec/1000); + MilliSleep(timeout.tv_usec/1000); } @@ -1076,7 +1076,7 @@ void ThreadSocketHandler2(void* parg) pnode->Release(); } - Sleep(10); + MilliSleep(10); } } @@ -1197,7 +1197,7 @@ void ThreadMapPort2(void* parg) else printf("UPnP Port Mapping successful.\n");; } - Sleep(2000); + MilliSleep(2000); i++; } } else { @@ -1208,7 +1208,7 @@ void ThreadMapPort2(void* parg) loop { if (fShutdown || !fUseUPnP) return; - Sleep(2000); + MilliSleep(2000); } } } @@ -1418,7 +1418,7 @@ void ThreadDumpAddress2(void* parg) { DumpAddresses(); vnThreadsRunning[THREAD_DUMPADDRESS]--; - Sleep(100000); + MilliSleep(100000); vnThreadsRunning[THREAD_DUMPADDRESS]++; } vnThreadsRunning[THREAD_DUMPADDRESS]--; @@ -1494,12 +1494,12 @@ void ThreadOpenConnections2(void* parg) OpenNetworkConnection(addr, NULL, strAddr.c_str()); for (int i = 0; i < 10 && i < nLoop; i++) { - Sleep(500); + MilliSleep(500); if (fShutdown) return; } } - Sleep(500); + MilliSleep(500); } } @@ -1510,7 +1510,7 @@ void ThreadOpenConnections2(void* parg) ProcessOneShot(); vnThreadsRunning[THREAD_OPENCONNECTIONS]--; - Sleep(500); + MilliSleep(500); vnThreadsRunning[THREAD_OPENCONNECTIONS]++; if (fShutdown) return; @@ -1642,12 +1642,12 @@ void ThreadOpenAddedConnections2(void* parg) CAddress addr; CSemaphoreGrant grant(*semOutbound); OpenNetworkConnection(addr, &grant, strAddNode.c_str()); - Sleep(500); + MilliSleep(500); if (fShutdown) return; } vnThreadsRunning[THREAD_ADDEDCONNECTIONS]--; - Sleep(120000); // Retry every 2 minutes + MilliSleep(120000); // Retry every 2 minutes vnThreadsRunning[THREAD_ADDEDCONNECTIONS]++; } return; @@ -1694,14 +1694,14 @@ void ThreadOpenAddedConnections2(void* parg) { CSemaphoreGrant grant(*semOutbound); OpenNetworkConnection(CAddress(vserv[i % vserv.size()]), &grant); - Sleep(500); + MilliSleep(500); if (fShutdown) return; } if (fShutdown) return; vnThreadsRunning[THREAD_ADDEDCONNECTIONS]--; - Sleep(120000); // Retry every 2 minutes + MilliSleep(120000); // Retry every 2 minutes vnThreadsRunning[THREAD_ADDEDCONNECTIONS]++; if (fShutdown) return; @@ -1821,7 +1821,7 @@ void ThreadMessageHandler2(void* parg) // Reduce vnThreadsRunning so StopNode has permission to exit while // we're sleeping, but we must always check fShutdown after doing this. vnThreadsRunning[THREAD_MESSAGEHANDLER]--; - Sleep(100); + MilliSleep(100); if (fRequestShutdown) StartShutdown(); vnThreadsRunning[THREAD_MESSAGEHANDLER]++; @@ -2068,7 +2068,7 @@ bool StopNode() break; if (GetTime() - nStart > 20) break; - Sleep(20); + MilliSleep(20); } while(true); if (vnThreadsRunning[THREAD_SOCKETHANDLER] > 0) printf("ThreadSocketHandler still running\n"); if (vnThreadsRunning[THREAD_OPENCONNECTIONS] > 0) printf("ThreadOpenConnections still running\n"); @@ -2082,8 +2082,8 @@ bool StopNode() if (vnThreadsRunning[THREAD_ADDEDCONNECTIONS] > 0) printf("ThreadOpenAddedConnections still running\n"); if (vnThreadsRunning[THREAD_DUMPADDRESS] > 0) printf("ThreadDumpAddresses still running\n"); while (vnThreadsRunning[THREAD_MESSAGEHANDLER] > 0 || vnThreadsRunning[THREAD_RPCHANDLER] > 0) - Sleep(20); - Sleep(50); + MilliSleep(20); + MilliSleep(50); DumpAddresses(); return true; |