diff options
author | Luke Dashjr <luke-jr+git@utopios.org> | 2012-09-10 23:42:59 +0000 |
---|---|---|
committer | Luke Dashjr <luke-jr+git@utopios.org> | 2012-09-10 23:42:59 +0000 |
commit | 9c82c574a00ca6151aa0f1f9824523c98aec8875 (patch) | |
tree | a0edb76c939fc303a402f9c836717d862f2d55cf /src/net.cpp | |
parent | 423cece29d7990fa73d8a4b19378552258863503 (diff) | |
parent | 6321b515f253fed372fedc742d64a0bab0f82d39 (diff) | |
download | bitcoin-9c82c574a00ca6151aa0f1f9824523c98aec8875.tar.xz |
Merge branch '0.5.x' into 0.6.0.x
Conflicts:
src/net.cpp
Diffstat (limited to 'src/net.cpp')
-rw-r--r-- | src/net.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/net.cpp b/src/net.cpp index 00d7e5a13e..5ccedb52d5 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -666,10 +666,14 @@ void ThreadSocketHandler2(void* parg) FD_ZERO(&fdsetSend); FD_ZERO(&fdsetError); SOCKET hSocketMax = 0; + bool have_fds = false; if(hListenSocket != INVALID_SOCKET) + { FD_SET(hListenSocket, &fdsetRecv); - hSocketMax = max(hSocketMax, hListenSocket); + hSocketMax = max(hSocketMax, hListenSocket); + have_fds = true; + } CRITICAL_BLOCK(cs_vNodes) { BOOST_FOREACH(CNode* pnode, vNodes) @@ -679,6 +683,7 @@ void ThreadSocketHandler2(void* parg) FD_SET(pnode->hSocket, &fdsetRecv); FD_SET(pnode->hSocket, &fdsetError); hSocketMax = max(hSocketMax, pnode->hSocket); + have_fds = true; TRY_CRITICAL_BLOCK(pnode->cs_vSend) if (!pnode->vSend.empty()) FD_SET(pnode->hSocket, &fdsetSend); @@ -686,15 +691,16 @@ void ThreadSocketHandler2(void* parg) } vnThreadsRunning[THREAD_SOCKETHANDLER]--; - int nSelect = select(hSocketMax + 1, &fdsetRecv, &fdsetSend, &fdsetError, &timeout); + int nSelect = select(have_fds ? hSocketMax + 1 : 0, + &fdsetRecv, &fdsetSend, &fdsetError, &timeout); vnThreadsRunning[THREAD_SOCKETHANDLER]++; if (fShutdown) return; if (nSelect == SOCKET_ERROR) { - int nErr = WSAGetLastError(); - if (hSocketMax != INVALID_SOCKET) + if (have_fds) { + int nErr = WSAGetLastError(); printf("socket select error %d\n", nErr); for (unsigned int i = 0; i <= hSocketMax; i++) FD_SET(i, &fdsetRecv); |