summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2023-09-29 20:05:43 +0100
committervaxerski <43317083+vaxerski@users.noreply.github.com>2023-09-29 20:05:43 +0100
commit4daa51570018900f12ede73f8bf73f6964a381bc (patch)
treedf7cd8e6c8d92e74c0d6d8a6ad2d61447657e7bd /src
parente07e64458e4ee5c42365bb05260b85723276d1c9 (diff)
watchdog: don't hang on exit
Diffstat (limited to 'src')
-rw-r--r--src/helpers/Watchdog.cpp6
-rw-r--r--src/helpers/Watchdog.hpp3
2 files changed, 8 insertions, 1 deletions
diff --git a/src/helpers/Watchdog.cpp b/src/helpers/Watchdog.cpp
index f5d85df7..2a26ee29 100644
--- a/src/helpers/Watchdog.cpp
+++ b/src/helpers/Watchdog.cpp
@@ -3,6 +3,9 @@
#include "config/ConfigManager.hpp"
CWatchdog::~CWatchdog() {
+ m_bExitThread = true;
+ m_bNotified = true;
+ m_cvWatchdogCondition.notify_all();
m_pWatchdog.reset();
}
@@ -22,6 +25,9 @@ CWatchdog::CWatchdog() {
pthread_kill(m_iMainThreadPID, SIGUSR1);
}
+ if (m_bExitThread)
+ break;
+
m_bWatching = false;
m_bNotified = false;
}
diff --git a/src/helpers/Watchdog.hpp b/src/helpers/Watchdog.hpp
index edbfb055..7bb499d6 100644
--- a/src/helpers/Watchdog.hpp
+++ b/src/helpers/Watchdog.hpp
@@ -24,7 +24,8 @@ class CWatchdog {
std::unique_ptr<std::thread> m_pWatchdog;
std::mutex m_mWatchdogMutex;
- bool m_bNotified = false;
+ bool m_bNotified = false;
+ bool m_bExitThread = false;
std::condition_variable m_cvWatchdogCondition;
};