- attempt safe socket code to avoid hangs

This commit is contained in:
SoftCoder 2015-12-23 21:37:35 -08:00
parent 9f55e9235a
commit ff2fb03c78
2 changed files with 4 additions and 4 deletions

View File

@ -1922,8 +1922,8 @@ NetworkMessageType ClientInterface::waitForMessage(int waitMicroseconds)
return msg;
}
// Sleep every x milli-seconds we wait to let other threads work
else if(chrono.getMillis() % 4 == 0) {
sleep(2);
else if(chrono.getMillis() % 10 == 0) {
sleep(3);
}
}

View File

@ -1700,12 +1700,12 @@ bool Socket::isReadable(bool lockMutex) {
fd_set set;
FD_ZERO(&set);
FD_SET(sock, &set);
MutexSafeWrapper safeMutex(NULL,CODE_AT_LINE);
if(lockMutex == true) {
safeMutex.setMutex(dataSynchAccessorRead,CODE_AT_LINE);
}
FD_SET(sock, &set);
int i = select((int)sock + 1, &set, NULL, NULL, &tv);
safeMutex.ReleaseLock();
@ -1735,12 +1735,12 @@ bool Socket::isWritable(struct timeval *timeVal, bool lockMutex) {
fd_set set;
FD_ZERO(&set);
FD_SET(sock, &set);
MutexSafeWrapper safeMutex(NULL,CODE_AT_LINE);
if(lockMutex == true) {
safeMutex.setMutex(dataSynchAccessorWrite,CODE_AT_LINE);
}
FD_SET(sock, &set);
int i = select((int)sock + 1, NULL, &set, NULL, &tv);
safeMutex.ReleaseLock();