From 0975b0196f8614d00661ae05089e35b0505b602b Mon Sep 17 00:00:00 2001 From: Sascha Philipp Date: Thu, 24 Apr 2014 10:16:22 +0200 Subject: Fix watchdog timeout Change-Id: Id6fe1a4948c7ca87e53042829f6b7eb7b9eec975 Signed-off-by: Ralf Anton Beier Signed-off-by: Sascha Philipp (cherry picked from commit 7f7afbb8d49cbdb8f571ece8aac24bf584326910) --- src/daemon/dlt-daemon.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c index fea6a4f..df6c567 100644 --- a/src/daemon/dlt-daemon.c +++ b/src/daemon/dlt-daemon.c @@ -71,6 +71,10 @@ static char str[DLT_DAEMON_TEXTBUFSIZE]; static int dlt_daemon_log_internal(DltDaemon *daemon, DltDaemonLocal *daemon_local, char *str, int verbose); +#ifdef DLT_SYSTEMD_WATCHDOG_ENABLE +static uint32_t watchdog_trigger_interval; // watchdog trigger interval in [s] +#endif + /** * Print usage information of tool. @@ -466,6 +470,7 @@ int main(int argc, char* argv[]) { watchdogTimeoutSeconds = atoi(watchdogUSec)/2000000; } + watchdog_trigger_interval = watchdogTimeoutSeconds; create_timer_fd(&daemon_local, watchdogTimeoutSeconds, watchdogTimeoutSeconds, &daemon_local.timer_wd, "Systemd watchdog"); } #endif @@ -2538,6 +2543,9 @@ int dlt_daemon_send_ringbuffer_to_client(DltDaemon *daemon, DltDaemonLocal *daem int ret; static uint8_t data[DLT_DAEMON_RCVBUFSIZE]; int length; +#ifdef DLT_SYSTEMD_WATCHDOG_ENABLE + uint32_t curr_time; +#endif PRINT_FUNCTION_VERBOSE(verbose); @@ -2553,8 +2561,26 @@ int dlt_daemon_send_ringbuffer_to_client(DltDaemon *daemon, DltDaemonLocal *daem return DLT_DAEMON_ERROR_OK; } +#ifdef DLT_SYSTEMD_WATCHDOG_ENABLE + if(sd_notify(0, "WATCHDOG=1") < 0) + { + dlt_log(LOG_WARNING, "Could not reset systemd watchdog\n"); + } + curr_time = dlt_uptime(); +#endif while ( (length = dlt_buffer_copy(&(daemon->client_ringbuffer), data, sizeof(data)) ) > 0) { +#ifdef DLT_SYSTEMD_WATCHDOG_ENABLE + if ((dlt_uptime() - curr_time) / 10000 >= watchdog_trigger_interval) + { + if(sd_notify(0, "WATCHDOG=1") < 0) + { + dlt_log(LOG_WARNING, "Could not reset systemd watchdog\n"); + } + curr_time = dlt_uptime(); + } +#endif + if((ret = dlt_daemon_client_send(DLT_DAEMON_SEND_FORCE,daemon,daemon_local,data,length,0,0,verbose,0))) { return ret; -- cgit v1.2.1