refactor: Remove RetryOnFailure, Client will always retry and Server will never retry
This commit is contained in:
committed by
Chris Rizzitello
parent
8c6fa880b4
commit
f4ca17ba3d
@ -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.
|
||||
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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<Client::FailInfo> info(static_cast<Client::FailInfo *>(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()
|
||||
|
||||
@ -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()
|
||||
|
||||
Reference in New Issue
Block a user