From 2f100f2ba3990da505f81934285c7d9a172a98b4 Mon Sep 17 00:00:00 2001 From: ebbit1q Date: Thu, 1 Sep 2022 02:38:10 +0200 Subject: [PATCH] fix keepalive being multiplied in server timeout (#4663) * fix keepalive being multiplied in server timeout a timeout happened after the client not receiving anything for keepalive * keepalive * maxtimeout (5 * 5 * 10) seconds instead of what you'd expect, it now only uses keepalive once instead of twice this means it should now take 50 seconds to time out when disconnected * change timeout to 15 seconds instead change time between pings to 3 from 5 seconds change timout to 5 from 10 repeats --- cockatrice/src/remoteclient.cpp | 3 +-- cockatrice/src/remoteclient.h | 2 +- cockatrice/src/settingscache.cpp | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cockatrice/src/remoteclient.cpp b/cockatrice/src/remoteclient.cpp index 4ade3b08..78dc02db 100644 --- a/cockatrice/src/remoteclient.cpp +++ b/cockatrice/src/remoteclient.cpp @@ -541,10 +541,9 @@ void RemoteClient::ping() } } - int keepalive = SettingsCache::instance().getKeepAlive(); int maxTime = timeRunning - lastDataReceived; emit maxPingTime(maxTime, maxTimeout); - if (maxTime >= (keepalive * maxTimeout)) { + if (maxTime >= maxTimeout) { disconnectFromServer(); emit serverTimeout(); } else { diff --git a/cockatrice/src/remoteclient.h b/cockatrice/src/remoteclient.h index e87f306b..1e0464ed 100644 --- a/cockatrice/src/remoteclient.h +++ b/cockatrice/src/remoteclient.h @@ -89,7 +89,7 @@ private slots: void submitForgotPasswordChallengeResponse(const Response &response); private: - static const int maxTimeout = 10; + static const int maxTimeout = 5; int timeRunning, lastDataReceived; QByteArray inputBuffer; bool messageInProgress; diff --git a/cockatrice/src/settingscache.cpp b/cockatrice/src/settingscache.cpp index 125a7354..8e95fe4b 100644 --- a/cockatrice/src/settingscache.cpp +++ b/cockatrice/src/settingscache.cpp @@ -181,7 +181,7 @@ SettingsCache::SettingsCache() updateReleaseChannel = settings->value("personal/updatereleasechannel", 0).toInt(); lang = settings->value("personal/lang").toString(); - keepalive = settings->value("personal/keepalive", 5).toInt(); + keepalive = settings->value("personal/keepalive", 3).toInt(); // tip of the day settings showTipsOnStartup = settings->value("tipOfDay/showTips", true).toBool();