refactor: CoreProcess::onProcessFinished Stop trying to restart the core process if its already running

This commit is contained in:
sithlord48 2025-08-21 21:49:46 -04:00 committed by Nick Bolton
parent 97e3524a24
commit d368b92165

View file

@ -6,6 +6,7 @@
#include "CoreProcess.h" #include "CoreProcess.h"
#include "common/ExitCodes.h"
#include "common/Settings.h" #include "common/Settings.h"
#include "gui/ipc/DaemonIpcClient.h" #include "gui/ipc/DaemonIpcClient.h"
#include "tls/TlsUtility.h" #include "tls/TlsUtility.h"
@ -196,23 +197,24 @@ void CoreProcess::daemonIpcClientConnected()
void CoreProcess::onProcessFinished(int exitCode, QProcess::ExitStatus) void CoreProcess::onProcessFinished(int exitCode, QProcess::ExitStatus)
{ {
const auto wasStarted = m_processState == ProcessState::Started;
setConnectionState(ConnectionState::Disconnected); setConnectionState(ConnectionState::Disconnected);
if (exitCode == 0) { if (m_retryTimer.isActive()) {
qDebug("desktop process exited normally"); m_retryTimer.stop();
} else {
qWarning("desktop process exited with error code: %d", exitCode);
} }
if (wasStarted) { if (exitCode == s_exitSuccess) {
qDebug("desktop process exited normally");
} else if (exitCode != s_exitDuplicate) {
qWarning("desktop process exited with error code: %d", exitCode);
} else {
setProcessState(ProcessState::Stopped);
qWarning("desktop process is already running");
return;
}
if (const auto wasStarted = m_processState == ProcessState::Started; wasStarted) {
qDebug("desktop process was running, retrying in %d ms", kRetryDelay); qDebug("desktop process was running, retrying in %d ms", kRetryDelay);
if (m_retryTimer.isActive()) {
m_retryTimer.stop();
}
setProcessState(ProcessState::RetryPending); setProcessState(ProcessState::RetryPending);
m_retryTimer.setSingleShot(true); m_retryTimer.setSingleShot(true);
m_retryTimer.start(kRetryDelay); m_retryTimer.start(kRetryDelay);