From 0dbf879e7db84ea8a0b71633161eb5244db1cbd3 Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 2 Sep 2014 00:16:17 +0100 Subject: [PATCH] Add small timeouts to blocking recv/send so we don't spin forever --- renderdoc/os/win32/win32_network.cpp | 12 ++++++++++++ renderdocui/Interop/StaticExports.cs | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/renderdoc/os/win32/win32_network.cpp b/renderdoc/os/win32/win32_network.cpp index 0afe203d6..ee959e3d8 100644 --- a/renderdoc/os/win32/win32_network.cpp +++ b/renderdoc/os/win32/win32_network.cpp @@ -103,6 +103,9 @@ bool Socket::SendDataBlocking(const void *buf, uint32_t length) u_long enable = 0; ioctlsocket(socket, FIONBIO, &enable); + + DWORD timeout = 3000; + setsockopt(socket, SOL_SOCKET, SO_SNDTIMEO, (const char *)&timeout, sizeof(timeout)); while(sent < length) { @@ -131,6 +134,9 @@ bool Socket::SendDataBlocking(const void *buf, uint32_t length) enable = 1; ioctlsocket(socket, FIONBIO, &enable); + timeout = 600000; + setsockopt(socket, SOL_SOCKET, SO_SNDTIMEO, (const char *)&timeout, sizeof(timeout)); + RDCASSERT(sent == length); return true; @@ -175,6 +181,9 @@ bool Socket::RecvDataBlocking(void *buf, uint32_t length) u_long enable = 0; ioctlsocket(socket, FIONBIO, &enable); + + DWORD timeout = 3000; + setsockopt(socket, SOL_SOCKET, SO_RCVTIMEO, (const char *)&timeout, sizeof(timeout)); while(received < length) { @@ -207,6 +216,9 @@ bool Socket::RecvDataBlocking(void *buf, uint32_t length) enable = 1; ioctlsocket(socket, FIONBIO, &enable); + + timeout = 600000; + setsockopt(socket, SOL_SOCKET, SO_RCVTIMEO, (const char *)&timeout, sizeof(timeout)); RDCASSERT(received == length); diff --git a/renderdocui/Interop/StaticExports.cs b/renderdocui/Interop/StaticExports.cs index af5a7acf6..4dcf43fc9 100644 --- a/renderdocui/Interop/StaticExports.cs +++ b/renderdocui/Interop/StaticExports.cs @@ -110,7 +110,7 @@ namespace renderdoc if (rendPtr == IntPtr.Zero) { - var e = new System.ApplicationException("Failed to load log for local replay"); + var e = new System.ApplicationException("Failed to open remote access connection"); e.Data.Add("status", ReplayCreateStatus.UnknownError); throw e; }