From f4ca17ba3d43a23fe37b8ea2f84f54d90f4e43ae Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Tue, 28 Oct 2025 17:15:24 -0400 Subject: [PATCH] refactor: Remove RetryOnFailure, Client will always retry and Server will never retry --- src/lib/base/EventTypes.h | 3 --- src/lib/client/Client.cpp | 4 ---- src/lib/common/Settings.cpp | 7 +++---- src/lib/common/Settings.h | 2 -- src/lib/deskflow/ClientApp.cpp | 18 +++++------------- src/lib/deskflow/ServerApp.cpp | 33 +++------------------------------ 6 files changed, 11 insertions(+), 56 deletions(-) diff --git a/src/lib/base/EventTypes.h b/src/lib/base/EventTypes.h index 15dfc445d..4be75a252 100644 --- a/src/lib/base/EventTypes.h +++ b/src/lib/base/EventTypes.h @@ -86,9 +86,6 @@ enum class EventTypes : uint32_t */ SocketDisconnected, - /// This is sent when the client doesn't want to reconnect after it disconnects from the server. - SocketStopRetry, - OsxScreenConfirmSleep, /// This event is sent whenever a server accepts a client. diff --git a/src/lib/client/Client.cpp b/src/lib/client/Client.cpp index 70ec64a7a..2f00700e7 100644 --- a/src/lib/client/Client.cpp +++ b/src/lib/client/Client.cpp @@ -420,9 +420,6 @@ void Client::setupConnection() m_events->addHandler(EventTypes::StreamOutputShutdown, m_stream->getEventTarget(), [this](const auto &) { handleDisconnected(); }); - m_events->addHandler(EventTypes::SocketStopRetry, m_stream->getEventTarget(), [this](const auto &) { - Settings::setValue(Settings::Core::RestartOnFailure, false); - }); } void Client::setupScreen() @@ -472,7 +469,6 @@ void Client::cleanupConnection() m_events->removeHandler(StreamInputShutdown, m_stream->getEventTarget()); m_events->removeHandler(StreamOutputShutdown, m_stream->getEventTarget()); m_events->removeHandler(SocketDisconnected, m_stream->getEventTarget()); - m_events->removeHandler(SocketStopRetry, m_stream->getEventTarget()); cleanupStream(); } } diff --git a/src/lib/common/Settings.cpp b/src/lib/common/Settings.cpp index 9909c2fe6..e2051873d 100644 --- a/src/lib/common/Settings.cpp +++ b/src/lib/common/Settings.cpp @@ -114,10 +114,9 @@ QVariant Settings::defaultValue(const QString &key) return false; } - if ((key == Core::RestartOnFailure) || (key == Core::UseHooks) || (key == Gui::CloseToTray) || - (key == Gui::LogExpanded) || (key == Gui::SymbolicTrayIcon) || (key == Gui::CloseReminder) || - (key == Security::TlsEnabled) || (key == Security::CheckPeers) || (key == Client::LanguageSync) || - (key == Gui::ShowGenericClientFailureDialog)) { + if ((key == Core::UseHooks) || (key == Gui::CloseToTray) || (key == Gui::LogExpanded) || + (key == Gui::SymbolicTrayIcon) || (key == Gui::CloseReminder) || (key == Security::TlsEnabled) || + (key == Security::CheckPeers) || (key == Client::LanguageSync) || (key == Gui::ShowGenericClientFailureDialog)) { return true; } diff --git a/src/lib/common/Settings.h b/src/lib/common/Settings.h index 236bdf675..1067a0bfb 100644 --- a/src/lib/common/Settings.h +++ b/src/lib/common/Settings.h @@ -52,7 +52,6 @@ public: inline static const auto StartedBefore = QStringLiteral("core/startedBefore"); inline static const auto UpdateUrl = QStringLiteral("core/updateUrl"); inline static const auto Display = QStringLiteral("core/display"); - inline static const auto RestartOnFailure = QStringLiteral("core/restartOnFailure"); inline static const auto UseHooks = QStringLiteral("core/useHooks"); inline static const auto Language = QStringLiteral("core/language"); }; @@ -178,7 +177,6 @@ private: , Settings::Core::StartedBefore , Settings::Core::UpdateUrl , Settings::Core::Display - , Settings::Core::RestartOnFailure , Settings::Core::UseHooks , Settings::Core::Language , Settings::Daemon::Command diff --git a/src/lib/deskflow/ClientApp.cpp b/src/lib/deskflow/ClientApp.cpp index 49050d7ef..a9067d8ea 100644 --- a/src/lib/deskflow/ClientApp.cpp +++ b/src/lib/deskflow/ClientApp.cpp @@ -78,8 +78,7 @@ void ClientApp::parseArgs() // we'll try to resolve the address each time we connect to the // server. a bad port will never get better. patch by Brent // Priddy. - if (!Settings::value(Settings::Core::RestartOnFailure).toBool() || - e.getError() == SocketAddressException::SocketError::BadPort) { + if (e.getError() == SocketAddressException::SocketError::BadPort) { LOG_CRIT("%s: %s" BYE, qPrintable(processName()), e.what(), qPrintable(processName())); bye(s_exitFailed); } @@ -209,7 +208,7 @@ void ClientApp::handleClientRefused(const Event &e) { std::unique_ptr info(static_cast(e.getData())); - if (!Settings::value(Settings::Core::RestartOnFailure).toBool() || !info->m_retry) { + if (!info->m_retry) { LOG_ERR("failed to connect to server: %s", info->m_what.c_str()); getEvents()->addEvent(Event(EventTypes::Quit)); } else { @@ -223,9 +222,7 @@ void ClientApp::handleClientRefused(const Event &e) void ClientApp::handleClientDisconnected() { LOG_IPC("disconnected from server"); - if (!Settings::value(Settings::Core::RestartOnFailure).toBool()) { - getEvents()->addEvent(Event(EventTypes::Quit)); - } else if (!m_suspended) { + if (!m_suspended) { scheduleClientRestart(s_retryTime); } } @@ -300,13 +297,8 @@ bool ClientApp::startClient() return false; } - if (Settings::value(Settings::Core::RestartOnFailure).toBool()) { - scheduleClientRestart(retryTime); - return true; - } else { - // don't try again - return false; - } + scheduleClientRestart(retryTime); + return true; } void ClientApp::stopClient() diff --git a/src/lib/deskflow/ServerApp.cpp b/src/lib/deskflow/ServerApp.cpp index 2a21413f1..f4d43edff 100644 --- a/src/lib/deskflow/ServerApp.cpp +++ b/src/lib/deskflow/ServerApp.cpp @@ -332,18 +332,7 @@ bool ServerApp::initServer() return false; } - if (Settings::value(Settings::Core::RestartOnFailure).toBool()) { - // install a timer and handler to retry later - assert(m_timer == nullptr); - LOG_DEBUG("retry in %.0f seconds", retryTime); - m_timer = getEvents()->newOneShotTimer(retryTime, nullptr); - getEvents()->addHandler(EventTypes::Timer, m_timer, [this](const auto &) { retryHandler(); }); - m_serverState = Initializing; - return true; - } else { - // don't try again - return false; - } + return false; } deskflow::Screen *ServerApp::openServerScreen() @@ -392,11 +381,7 @@ bool ServerApp::startServer() m_serverState = Started; return true; } catch (SocketAddressInUseException &e) { - if (Settings::value(Settings::Core::RestartOnFailure).toBool()) { - LOG_ERR("cannot listen for clients: %s", e.what()); - } else { - LOG_CRIT("cannot listen for clients: %s", e.what()); - } + LOG_CRIT("cannot listen for clients: %s", e.what()); closeClientListener(listener); } catch (BaseException &e) { LOG_CRIT("failed to start server: %s", e.what()); @@ -404,19 +389,7 @@ bool ServerApp::startServer() return false; } - if (Settings::value(Settings::Core::RestartOnFailure).toBool()) { - // install a timer and handler to retry later - assert(m_timer == nullptr); - const auto retryTime = 10.0; - LOG_DEBUG("retry in %.0f seconds", retryTime); - m_timer = getEvents()->newOneShotTimer(retryTime, nullptr); - getEvents()->addHandler(EventTypes::Timer, m_timer, [this](const auto &) { retryHandler(); }); - m_serverState = Starting; - return true; - } else { - // don't try again - return false; - } + return false; } deskflow::Screen *ServerApp::createScreen()