From 63dc0a4f5e95e9e3d6d74db1fa99fa3067b0d5cf Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Sat, 27 Jan 2024 11:23:25 +0100 Subject: [PATCH] Fix: update server as offline when unexpected disconnect during refresh (#11891) (cherry picked from commit 2bbc95cac370d206a9926e801a37a3bab9b3a813) --- src/network/network_query.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/network/network_query.cpp b/src/network/network_query.cpp index a9a020a5d1..569a58adfc 100644 --- a/src/network/network_query.cpp +++ b/src/network/network_query.cpp @@ -12,6 +12,7 @@ #include "network_query.h" #include "network_gamelist.h" #include "../error.h" +#include "../debug_fmt.h" #include "table/strings.h" @@ -24,6 +25,15 @@ NetworkRecvStatus QueryNetworkGameSocketHandler::CloseConnection(NetworkRecvStat assert(status != NETWORK_RECV_STATUS_OKAY); assert(this->sock != INVALID_SOCKET); + /* Connection is closed, but we never received a packet. Must be offline. */ + NetworkGameList *item = NetworkGameListAddItem(this->connection_string); + if (item->refreshing) { + item->status = NGLS_OFFLINE; + item->refreshing = false; + + UpdateNetworkGameWindow(); + } + return status; } @@ -36,6 +46,7 @@ bool QueryNetworkGameSocketHandler::CheckConnection() /* If there was no response in 5 seconds, terminate the query. */ if (lag > std::chrono::seconds(5)) { + Debug(net, 0, "Timeout while waiting for response from {}", this->connection_string); this->CloseConnection(NETWORK_RECV_STATUS_CONNECTION_LOST); return false; }