Add small timeouts to blocking recv/send so we don't spin forever

This commit is contained in:
baldurk
2014-09-02 00:16:17 +01:00
parent 3020e5ce95
commit 0dbf879e7d
2 changed files with 13 additions and 1 deletions
+12
View File
@@ -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);
+1 -1
View File
@@ -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;
}