mirror of
https://github.com/glest/glest-source.git
synced 2025-08-17 21:51:17 +02:00
- last try to optimize socket thread locks
This commit is contained in:
@@ -1700,28 +1700,13 @@ bool Socket::isReadable(bool lockMutex) {
|
|||||||
|
|
||||||
fd_set set;
|
fd_set set;
|
||||||
FD_ZERO(&set);
|
FD_ZERO(&set);
|
||||||
|
FD_SET(sock, &set);
|
||||||
if(isSocketValid() == false) return false;
|
|
||||||
|
|
||||||
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 = 0;
|
|
||||||
{
|
|
||||||
//MutexSafeWrapper safeMutexSocketDestructorFlag(&inSocketDestructorSynchAccessor,CODE_AT_LINE);
|
|
||||||
//if(this->inSocketDestructor == true) {
|
|
||||||
// SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] this->inSocketDestructor == true\n",__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
// return false;
|
|
||||||
//}
|
|
||||||
//inSocketDestructorSynchAccessor->setOwnerId(CODE_AT_LINE);
|
|
||||||
//safeMutexSocketDestructorFlag.ReleaseLock();
|
|
||||||
|
|
||||||
//MutexSafeWrapper safeMutex(&dataSynchAccessorRead,CODE_AT_LINE);
|
|
||||||
i= select((int)sock + 1, &set, NULL, NULL, &tv);
|
|
||||||
}
|
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
if(i < 0) {
|
if(i < 0) {
|
||||||
@@ -1733,7 +1718,6 @@ bool Socket::isReadable(bool lockMutex) {
|
|||||||
//if(result == false) {
|
//if(result == false) {
|
||||||
// SystemFlags::OutputDebug(SystemFlags::debugError,"SOCKET DISCONNECTED In [%s::%s Line: %d] i = %d sock = %d\n",__FILE__,__FUNCTION__,__LINE__,i,sock);
|
// SystemFlags::OutputDebug(SystemFlags::debugError,"SOCKET DISCONNECTED In [%s::%s Line: %d] i = %d sock = %d\n",__FILE__,__FUNCTION__,__LINE__,i,sock);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1746,35 +1730,20 @@ bool Socket::isWritable(struct timeval *timeVal, bool lockMutex) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tv.tv_sec= 0;
|
tv.tv_sec= 0;
|
||||||
//tv.tv_usec= 1;
|
|
||||||
tv.tv_usec= 0;
|
tv.tv_usec= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
fd_set set;
|
fd_set set;
|
||||||
FD_ZERO(&set);
|
FD_ZERO(&set);
|
||||||
|
FD_SET(sock, &set);
|
||||||
if(isSocketValid() == false) return false;
|
|
||||||
|
|
||||||
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 = 0;
|
|
||||||
{
|
|
||||||
//MutexSafeWrapper safeMutexSocketDestructorFlag(&inSocketDestructorSynchAccessor,CODE_AT_LINE);
|
|
||||||
//if(this->inSocketDestructor == true) {
|
|
||||||
// SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] this->inSocketDestructor == true\n",__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
// return false;
|
|
||||||
//}
|
|
||||||
//inSocketDestructorSynchAccessor->setOwnerId(CODE_AT_LINE);
|
|
||||||
//safeMutexSocketDestructorFlag.ReleaseLock();
|
|
||||||
|
|
||||||
//MutexSafeWrapper safeMutex(&dataSynchAccessorWrite,CODE_AT_LINE);
|
|
||||||
i = select((int)sock + 1, NULL, &set, NULL, &tv);
|
|
||||||
}
|
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
bool result = false;
|
bool result = false;
|
||||||
if(i < 0 ) {
|
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());
|
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());
|
||||||
|
Reference in New Issue
Block a user