mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Fix RCON disconnect bug
RCON occasionally did NOT disconnect, but only if the socket has been closed improperly. If the server/client crashes for example, the connection remained open in RCON; pendingLen on the initial peek recv < 0 while socket isn't blocking means socket has been closed unexpectedly.
This commit is contained in:
parent
309e297ae4
commit
10ee88ec10
@ -88,6 +88,11 @@ void CNetConBase::Recv(CConnectedNetConsoleData& pData, const int nMaxLen)
|
||||
Disconnect("remote closed socket");
|
||||
return;
|
||||
}
|
||||
else if (nPendingLen < 0)
|
||||
{
|
||||
Disconnect("socket closed unexpectedly");
|
||||
return;
|
||||
}
|
||||
}//////////////////////////////////////////////
|
||||
|
||||
int nReadLen = 0; // Find out how much we have to read.
|
||||
@ -104,7 +109,7 @@ void CNetConBase::Recv(CConnectedNetConsoleData& pData, const int nMaxLen)
|
||||
const int nRecvLen = ::recv(pData.m_hSocket, szRecvBuf, MIN(sizeof(szRecvBuf), nReadLen), MSG_NOSIGNAL);
|
||||
if (nRecvLen == 0) // Socket was closed.
|
||||
{
|
||||
Disconnect("socket closed unexpectedly");
|
||||
Disconnect("socket closed");
|
||||
break;
|
||||
}
|
||||
if (nRecvLen < 0 && !m_Socket.IsSocketBlocking())
|
||||
|
Loading…
x
Reference in New Issue
Block a user