From f8c6ed8028300aae8f9cdc6e4e35c8116a63b08f Mon Sep 17 00:00:00 2001 From: Koncord Date: Fri, 26 May 2017 03:02:07 +0800 Subject: [PATCH] [Browser] Fix freeze when server is unreachable --- apps/browser/netutils/Utils.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/browser/netutils/Utils.cpp b/apps/browser/netutils/Utils.cpp index 31512536d..c4765e7b1 100644 --- a/apps/browser/netutils/Utils.cpp +++ b/apps/browser/netutils/Utils.cpp @@ -25,8 +25,13 @@ unsigned int PingRakNetServer(const char *addr, unsigned short port) peer->Startup(1, &socketDescriptor, 1); if (!peer->Ping(addr, port, false)) return time; + RakNet::TimeMS start = RakNet::GetTimeMS(); while (!done) { + RakNet::TimeMS now = RakNet::GetTimeMS(); + if(now - start >= PING_UNREACHABLE) + break; + packet = peer->Receive(); if (!packet) continue; @@ -41,7 +46,7 @@ unsigned int PingRakNetServer(const char *addr, unsigned short port) case ID_UNCONNECTED_PONG: RakNet::BitStream bsIn(&packet->data[1], packet->length, false); bsIn.Read(time); - time = RakNet::GetTimeMS() - time; + time = now - time; done = true; break; }