mirror of
https://github.com/glest/glest-source.git
synced 2025-08-20 07:01:21 +02:00
- attempt safe socket code to avoid hangs
This commit is contained in:
@@ -1922,8 +1922,8 @@ NetworkMessageType ClientInterface::waitForMessage(int waitMicroseconds)
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
// Sleep every x milli-seconds we wait to let other threads work
|
// Sleep every x milli-seconds we wait to let other threads work
|
||||||
else if(chrono.getMillis() % 4 == 0) {
|
else if(chrono.getMillis() % 10 == 0) {
|
||||||
sleep(2);
|
sleep(3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1700,12 +1700,12 @@ bool Socket::isReadable(bool lockMutex) {
|
|||||||
|
|
||||||
fd_set set;
|
fd_set set;
|
||||||
FD_ZERO(&set);
|
FD_ZERO(&set);
|
||||||
FD_SET(sock, &set);
|
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(NULL,CODE_AT_LINE);
|
MutexSafeWrapper safeMutex(NULL,CODE_AT_LINE);
|
||||||
if(lockMutex == true) {
|
if(lockMutex == true) {
|
||||||
safeMutex.setMutex(dataSynchAccessorRead,CODE_AT_LINE);
|
safeMutex.setMutex(dataSynchAccessorRead,CODE_AT_LINE);
|
||||||
}
|
}
|
||||||
|
FD_SET(sock, &set);
|
||||||
int i = select((int)sock + 1, &set, NULL, NULL, &tv);
|
int i = select((int)sock + 1, &set, NULL, NULL, &tv);
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
@@ -1735,12 +1735,12 @@ bool Socket::isWritable(struct timeval *timeVal, bool lockMutex) {
|
|||||||
|
|
||||||
fd_set set;
|
fd_set set;
|
||||||
FD_ZERO(&set);
|
FD_ZERO(&set);
|
||||||
FD_SET(sock, &set);
|
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(NULL,CODE_AT_LINE);
|
MutexSafeWrapper safeMutex(NULL,CODE_AT_LINE);
|
||||||
if(lockMutex == true) {
|
if(lockMutex == true) {
|
||||||
safeMutex.setMutex(dataSynchAccessorWrite,CODE_AT_LINE);
|
safeMutex.setMutex(dataSynchAccessorWrite,CODE_AT_LINE);
|
||||||
}
|
}
|
||||||
|
FD_SET(sock, &set);
|
||||||
int i = select((int)sock + 1, NULL, &set, NULL, &tv);
|
int i = select((int)sock + 1, NULL, &set, NULL, &tv);
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user