chore: Add mutex for process state management in MSWindowsWatchdog
This commit is contained in:
parent
1bd3f5060e
commit
5eac984757
2 changed files with 9 additions and 1 deletions
|
|
@ -171,6 +171,8 @@ void MSWindowsWatchdog::mainLoop(void *)
|
|||
|
||||
LOG_DEBUG("starting watchdog main loop");
|
||||
while (m_running) {
|
||||
std::unique_lock lock(m_processStateMutex);
|
||||
|
||||
if (!m_command.empty() && !m_foreground && m_session.hasChanged()) {
|
||||
LOG_DEBUG("session changed, queueing process start");
|
||||
m_processState = ProcessState::StartPending;
|
||||
|
|
@ -228,6 +230,8 @@ void MSWindowsWatchdog::mainLoop(void *)
|
|||
} break;
|
||||
}
|
||||
|
||||
lock.unlock();
|
||||
|
||||
// TODO: This seems like a hack, why would we need to send the SAS function every loop iteration?
|
||||
// This slows down both the process relaunch speed and the watchdog thread loop shut down time.
|
||||
sendSas();
|
||||
|
|
@ -328,7 +332,9 @@ void MSWindowsWatchdog::startProcess()
|
|||
|
||||
void MSWindowsWatchdog::setProcessConfig(const std::string_view &command, bool elevate)
|
||||
{
|
||||
LOG_DEBUG("watchdog process config updated");
|
||||
LOG_DEBUG("updating watchdog process config");
|
||||
std::unique_lock lock(m_processStateMutex);
|
||||
|
||||
m_command = command;
|
||||
m_elevateProcess = elevate;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#include <Windows.h>
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
|
|
@ -161,4 +162,5 @@ private:
|
|||
ProcessState m_processState = ProcessState::Idle;
|
||||
std::string m_command = "";
|
||||
SendSas m_sendSasFunc = nullptr;
|
||||
std::mutex m_processStateMutex;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue