From 9d08f62558ff2e7cf4a15ba6330dce0b8108d20a Mon Sep 17 00:00:00 2001 From: oy Date: Thu, 17 Jan 2019 17:52:33 +0100 Subject: [PATCH] cancel connection process when server is unreachable. closes #1975 --- src/engine/shared/network_conn.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/engine/shared/network_conn.cpp b/src/engine/shared/network_conn.cpp index 441e6f38f..f1c2020b5 100644 --- a/src/engine/shared/network_conn.cpp +++ b/src/engine/shared/network_conn.cpp @@ -196,6 +196,7 @@ int CNetConnection::Connect(NETADDR *pAddr) // init connection Reset(); + m_LastRecvTime = time_get(); m_PeerAddr = *pAddr; m_PeerToken = NET_TOKEN_NONE; SetToken(GenerateToken(pAddr)); @@ -378,6 +379,11 @@ int CNetConnection::Update() m_State = NET_CONNSTATE_ERROR; SetError("Timeout"); } + else if(State() == NET_CONNSTATE_TOKEN && (Now - m_LastRecvTime) > time_freq() * 5) + { + m_State = NET_CONNSTATE_ERROR; + SetError("Unable to connect to the server"); + } // fix resends if(m_Buffer.First())