mirror of
https://github.com/glest/glest-source.git
synced 2025-08-17 21:51:17 +02:00
- added a few more socket guards around invalid socket value
This commit is contained in:
@@ -1204,11 +1204,13 @@ int Socket::send(const void *data, int dataSize) {
|
|||||||
|
|
||||||
MutexSafeWrapper safeMutex(dataSynchAccessorWrite,CODE_AT_LINE);
|
MutexSafeWrapper safeMutex(dataSynchAccessorWrite,CODE_AT_LINE);
|
||||||
|
|
||||||
|
if(isSocketValid() == true) {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
bytesSent = ::send(sock, (const char *)data, dataSize, SO_NOSIGPIPE);
|
bytesSent = ::send(sock, (const char *)data, dataSize, SO_NOSIGPIPE);
|
||||||
#else
|
#else
|
||||||
bytesSent = ::send(sock, (const char *)data, dataSize, MSG_NOSIGNAL | MSG_DONTWAIT);
|
bytesSent = ::send(sock, (const char *)data, dataSize, MSG_NOSIGNAL | MSG_DONTWAIT);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1355,7 +1357,9 @@ int Socket::receive(void *data, int dataSize, bool tryReceiveUntilDataSizeMet) {
|
|||||||
// safeMutexSocketDestructorFlag.ReleaseLock();
|
// safeMutexSocketDestructorFlag.ReleaseLock();
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(dataSynchAccessorRead,CODE_AT_LINE);
|
MutexSafeWrapper safeMutex(dataSynchAccessorRead,CODE_AT_LINE);
|
||||||
bytesReceived = recv(sock, reinterpret_cast<char*>(data), dataSize, 0);
|
if(isSocketValid() == true) {
|
||||||
|
bytesReceived = recv(sock, reinterpret_cast<char*>(data), dataSize, 0);
|
||||||
|
}
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
}
|
}
|
||||||
if(bytesReceived < 0 && getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN) {
|
if(bytesReceived < 0 && getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN) {
|
||||||
@@ -1445,8 +1449,9 @@ int Socket::peek(void *data, int dataSize,bool mustGetData) {
|
|||||||
MutexSafeWrapper safeMutex(dataSynchAccessorRead,CODE_AT_LINE);
|
MutexSafeWrapper safeMutex(dataSynchAccessorRead,CODE_AT_LINE);
|
||||||
|
|
||||||
//if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis());
|
//if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis());
|
||||||
|
if(isSocketValid() == true) {
|
||||||
err = recv(sock, reinterpret_cast<char*>(data), dataSize, MSG_PEEK);
|
err = recv(sock, reinterpret_cast<char*>(data), dataSize, MSG_PEEK);
|
||||||
|
}
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
//printf("Peek #1 err = %d\n",err);
|
//printf("Peek #1 err = %d\n",err);
|
||||||
|
Reference in New Issue
Block a user