- attempt safe socket code to avoid hangs
This commit is contained in:
parent
9f55e9235a
commit
ff2fb03c78
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue