28 #include "audiomanagerconfig.h" 30 #include <systemd/sd-daemon.h> 37 mpCAmSocketHandler(CAmSocketHandler),
40 assert(mpCAmSocketHandler);
45 int watchdogTimeout = 0;
47 char* wusec=getenv(
"WATCHDOG_USEC");
49 watchdogTimeout=atoi(wusec);
51 if (watchdogTimeout > 0)
56 timeout.tv_sec = (watchdogTimeout / 2) / 1000000;
57 timeout.tv_nsec = ((watchdogTimeout / 2) % 1000000) * 1000;
58 logInfo(
"CAmWatchdog::CAmWatchdog setting watchdog timeout:", watchdogTimeout,
"us. Notification set to:",
59 (
int)timeout.tv_sec,
"sec and", (
int)timeout.tv_nsec,
"ns");
64 logError(
"CAmWatchdog::CAmWatchdog failed to add timer");
65 throw std::runtime_error(
"CAmWatchdog::CAmWatchdog failed to add timer");
71 logInfo(
"CAmWatchdog::CAmWatchdog watchdog timeout was ", watchdogTimeout,
" museconds, no watchdog active");
85 int error(sd_notify(0,
"WATCHDOG=1"));
88 logError(
"CAmWatchdog::timerCallback could not reset watchdog, error ", error);
89 throw std::runtime_error(
"CAmWatchdog::timerCallback could not reset watchdog");
97 int error(sd_notify(0,
"READY=1"));
100 logError(
"CAmWatchdog::startWatchdog could not start watchdog, error ", error);
101 throw std::runtime_error(
"CAmWatchdog::startWatchdog could not start watchdog");
103 logInfo(
"READY=1 was sent to systemd");
A Common-API wrapper class, which loads the common-api runtime and instantiates all necessary objects...
void logInfo(T value, TArgs...args)
logs given values with infolevel with the default context
am_Error_e restartTimer(const sh_timerHandle_t handle)
restarts a timer with the original value
The am::CAmSocketHandler implements a mainloop for the AudioManager.
Implements the watchdog of the AudioManager with the help of systemd.
SPDX license identifier: MPL-2.0.
SPDX license identifier: MPL-2.0.
am_Error_e removeTimer(const sh_timerHandle_t handle)
removes a timer from the list of timers
CAmWatchdog(CAmSocketHandler *CAmSocketHandler)
void startWatchdog()
starts the watchdog by sending ready to systemD
void logError(T value, TArgs...args)
logs given values with errorlevel with the default context
TAmShTimerCallBack< CAmWatchdog > TimerCallback
void timerCallback(sh_timerHandle_t handle, void *userData)
the watchdog timer callback
sh_pollHandle_t sh_timerHandle_t
this is a handle for a timer to be used with the SocketHandler
am_Error_e addTimer(const timespec &timeouts, IAmShTimerCallBack *callback, sh_timerHandle_t &handle, void *userData, const bool __attribute__((__unused__)) repeats=false)