- bugfixes for detecting client disconnection
This commit is contained in:
parent
cb96232256
commit
b805308a42
|
@ -1458,6 +1458,8 @@ void ConnectionSlot::close() {
|
|||
//printf("Closing connection slot!\n");
|
||||
//}
|
||||
|
||||
//printf("ConnectionSlot::close() #1 this->getSocket() = %p\n",this->getSocket());
|
||||
|
||||
this->gotIntro = false;
|
||||
this->skipLagCheck = false;
|
||||
this->joinGameInProgress = false;
|
||||
|
@ -1475,9 +1477,14 @@ void ConnectionSlot::close() {
|
|||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
//printf("ConnectionSlot::close() #2 this->getSocket() = %p\n",this->getSocket());
|
||||
|
||||
MutexSafeWrapper safeMutex(mutexCloseConnection,CODE_AT_LINE);
|
||||
|
||||
bool updateServerListener = (this->getSocket() != NULL);
|
||||
|
||||
//printf("ConnectionSlot::close() #3 this->getSocket() = %p updateServerListener = %d\n",this->getSocket(),updateServerListener);
|
||||
|
||||
this->deleteSocket();
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
|
|
|
@ -949,7 +949,7 @@ Socket::~Socket() {
|
|||
}
|
||||
|
||||
void Socket::disconnectSocket() {
|
||||
//printf("Socket disconnecting\n");
|
||||
//printf("Socket disconnecting sock = %d\n",sock);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] START closing socket = %d...\n",__FILE__,__FUNCTION__,sock);
|
||||
|
||||
|
@ -1511,6 +1511,11 @@ int Socket::peek(void *data, int dataSize,bool mustGetData,int *pLastSocketError
|
|||
|
||||
// if(recvTimer.getMillis() > 1000 || (err <= 0 && lastSocketError != 0 && lastSocketError != PLATFORM_SOCKET_TRY_AGAIN)) {
|
||||
// printf("#1 PEEK err = %d lastSocketError = %d ms: %lld\n",err,lastSocketError,(long long int)recvTimer.getMillis());
|
||||
|
||||
//if(err != dataSize) {
|
||||
// printf("#1 PEEK err = %d lastSocketError = %d\n",err,lastSocketError);
|
||||
//}
|
||||
|
||||
// }
|
||||
}
|
||||
safeMutex.ReleaseLock();
|
||||
|
@ -1782,7 +1787,9 @@ bool Socket::isConnected() {
|
|||
//int err = peek(&tmp, 1, false, &lastSocketError);
|
||||
int err = peek(&tmp, peekDataBytes, false, &lastSocketError);
|
||||
//if(err <= 0 && err != PLATFORM_SOCKET_TRY_AGAIN) {
|
||||
if(err <= 0 && lastSocketError != 0 && lastSocketError != PLATFORM_SOCKET_TRY_AGAIN) {
|
||||
//if(err <= 0 && lastSocketError != 0 && lastSocketError != PLATFORM_SOCKET_TRY_AGAIN) {
|
||||
if(err < 0 || (err == 0 && peekDataBytes != 0) ||
|
||||
((err == 0 || err == -1) && peekDataBytes == 0 && lastSocketError != 0 && lastSocketError != PLATFORM_SOCKET_TRY_AGAIN)) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s Line: %d] ERROR Peek failed, err = %d for socket: %d, error = %s, lastSocketError = %d\n",__FILE__,__FUNCTION__,__LINE__,err,sock,getLastSocketErrorFormattedText().c_str(),lastSocketError);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) SystemFlags::OutputDebug(SystemFlags::debugError,"SOCKET DISCONNECTED In [%s::%s Line: %d] ERROR Peek failed, err = %d for socket: %d, error = %s, lastSocketError = %d\n",__FILE__,__FUNCTION__,__LINE__,err,sock,getLastSocketErrorFormattedText().c_str(),lastSocketError);
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue
Block a user