make ubus handling use uloop timers
[project/procd.git] / watchdog.c
index 98961d3..2a516b4 100644 (file)
@@ -36,10 +36,23 @@ static void watchdog_timeout_cb(struct uloop_timeout *t)
 {
        DEBUG(2, "Ping\n");
        if (write(wdt_fd, "X", 1) < 0)
-               perror("WDT failed to write\n");
+               ERROR("WDT failed to write: %s\n", strerror(errno));
        uloop_timeout_set(t, wdt_frequency * 1000);
 }
 
+void watchdog_set_stopped(bool val)
+{
+       if (val)
+               uloop_timeout_cancel(&wdt_timeout);
+       else
+               watchdog_timeout_cb(&wdt_timeout);
+}
+
+bool watchdog_get_stopped(void)
+{
+       return !wdt_timeout.pending;
+}
+
 int watchdog_timeout(int timeout)
 {
        if (wdt_fd < 0)