From a1d0b72e793a25f06c2c1ddac46245ea27dcde13 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 24 Aug 2016 12:12:50 +0200 Subject: [PATCH] Fix select() calls - nfds must be the highest fd value plus 1 * This was copy-pasted from windows where unfortunately the nfds argument is ignored and we could get away with just passing 0 (which I suspect is where the broken code came from originally - a windows example code that passed 0) --- renderdoc/os/posix/posix_network.cpp | 11 +---------- renderdoc/os/win32/win32_network.cpp | 11 +---------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/renderdoc/os/posix/posix_network.cpp b/renderdoc/os/posix/posix_network.cpp index 7d722fcfc..2e8fcb572 100644 --- a/renderdoc/os/posix/posix_network.cpp +++ b/renderdoc/os/posix/posix_network.cpp @@ -311,7 +311,7 @@ Socket *CreateClientSocket(const char *host, uint16_t port, int timeoutMS) timeval timeout; timeout.tv_sec = (timeoutMS / 1000); timeout.tv_usec = (timeoutMS % 1000) * 1000; - result = select(0, NULL, &set, NULL, &timeout); + result = select(s + 1, NULL, &set, NULL, &timeout); if(result <= 0) { @@ -319,22 +319,13 @@ Socket *CreateClientSocket(const char *host, uint16_t port, int timeoutMS) close(s); continue; } - else - { - RDCDEBUG("connect before timeout"); - } } else { - RDCDEBUG("problem other than blocking"); close(s); continue; } } - else - { - RDCDEBUG("connected immediately"); - } int nodelay = 1; setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char *)&nodelay, sizeof(nodelay)); diff --git a/renderdoc/os/win32/win32_network.cpp b/renderdoc/os/win32/win32_network.cpp index 6078d9b83..ed8002512 100644 --- a/renderdoc/os/win32/win32_network.cpp +++ b/renderdoc/os/win32/win32_network.cpp @@ -326,7 +326,7 @@ Socket *CreateClientSocket(const char *host, uint16_t port, int timeoutMS) timeval timeout; timeout.tv_sec = (timeoutMS / 1000); timeout.tv_usec = (timeoutMS % 1000) * 1000; - result = select(0, NULL, &set, NULL, &timeout); + result = select((int)s + 1, NULL, &set, NULL, &timeout); if(result <= 0) { @@ -334,22 +334,13 @@ Socket *CreateClientSocket(const char *host, uint16_t port, int timeoutMS) closesocket(s); continue; } - else - { - RDCDEBUG("connect before timeout"); - } } else { - RDCDEBUG("problem other than blocking"); closesocket(s); continue; } } - else - { - RDCDEBUG("connected immediately"); - } BOOL nodelay = TRUE; setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (const char *)&nodelay, sizeof(nodelay));