From d2de4eb22a768f00bae5bda4585e7cffca0dfc52 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Tue, 9 Nov 2010 16:51:03 +0000 Subject: [PATCH] - change to properly toggle socket blocking mode in Linux --- source/shared_lib/sources/platform/posix/socket.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/source/shared_lib/sources/platform/posix/socket.cpp b/source/shared_lib/sources/platform/posix/socket.cpp index a64942f55..1f11c1701 100644 --- a/source/shared_lib/sources/platform/posix/socket.cpp +++ b/source/shared_lib/sources/platform/posix/socket.cpp @@ -1164,7 +1164,14 @@ void Socket::setBlock(bool block){ void Socket::setBlock(bool block, PLATFORM_SOCKET socket){ #ifndef WIN32 - int err= fcntl(socket, F_SETFL, block ? 0 : O_NONBLOCK); + int currentFlags = fcntl(socket, F_GETFL); + if(block == true) { + currentFlags |= O_NONBLOCK; + } + else { + currentFlags &= (~O_NONBLOCK); + } + int err= fcntl(socket, F_SETFL, currentFlags); #else u_long iMode= !block; int err= ioctlsocket(socket, FIONBIO, &iMode);