From a8b735ffcc9816612bc85abaf1ce61bdfa6b85db Mon Sep 17 00:00:00 2001 From: SoftCoder Date: Wed, 23 Dec 2015 12:42:39 -0800 Subject: [PATCH] - check to see if this corrects the current windows client hang in network games --- source/shared_lib/sources/platform/posix/socket.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source/shared_lib/sources/platform/posix/socket.cpp b/source/shared_lib/sources/platform/posix/socket.cpp index 60de346f..386ff3e3 100644 --- a/source/shared_lib/sources/platform/posix/socket.cpp +++ b/source/shared_lib/sources/platform/posix/socket.cpp @@ -1701,12 +1701,12 @@ bool Socket::isReadable(bool lockMutex) { fd_set set; FD_ZERO(&set); + if(isSocketValid() == false) return false; + MutexSafeWrapper safeMutex(NULL,CODE_AT_LINE); if(lockMutex == true) { - //safeMutex.setMutex(dataSynchAccessorRead,CODE_AT_LINE); + safeMutex.setMutex(dataSynchAccessorRead,CODE_AT_LINE); } - - if(isSocketValid() == false) return false; FD_SET(sock, &set); int i = 0; @@ -1722,6 +1722,8 @@ bool Socket::isReadable(bool lockMutex) { //MutexSafeWrapper safeMutex(&dataSynchAccessorRead,CODE_AT_LINE); i= select((int)sock + 1, &set, NULL, NULL, &tv); } + safeMutex.ReleaseLock(); + if(i < 0) { if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s] error while selecting socket data, err = %d, error = %s\n",__FILE__,__FUNCTION__,i,getLastSocketErrorFormattedText().c_str()); printf("In [%s::%s] Line: %d, ERROR SELECTING SOCKET DATA retval = %d error = %s\n",__FILE__,__FUNCTION__,__LINE__,i,getLastSocketErrorFormattedText().c_str()); @@ -1751,11 +1753,12 @@ bool Socket::isWritable(struct timeval *timeVal, bool lockMutex) { fd_set set; FD_ZERO(&set); + if(isSocketValid() == false) return false; + MutexSafeWrapper safeMutex(NULL,CODE_AT_LINE); if(lockMutex == true) { safeMutex.setMutex(dataSynchAccessorWrite,CODE_AT_LINE); } - if(isSocketValid() == false) return false; FD_SET(sock, &set); int i = 0; @@ -1771,6 +1774,7 @@ bool Socket::isWritable(struct timeval *timeVal, bool lockMutex) { //MutexSafeWrapper safeMutex(&dataSynchAccessorWrite,CODE_AT_LINE); i = select((int)sock + 1, NULL, &set, NULL, &tv); } + safeMutex.ReleaseLock(); bool result = false; if(i < 0 ) { if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s Line: %d] error while selecting socket data, err = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,i,getLastSocketErrorFormattedText().c_str());