]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Adjust systemd watchdog support
authorNick Mathewson <nickm@torproject.org>
Tue, 23 Dec 2014 16:27:16 +0000 (11:27 -0500)
committerNick Mathewson <nickm@torproject.org>
Tue, 23 Dec 2014 16:27:18 +0000 (11:27 -0500)
Document why we divide it by two.

Check for > 0 instead of nonzero for success, since that's what the
manpage says.

Allow watchdog timers greater than 1 second.

src/or/main.c

index 5a17212da648722b38e5b305fe23251c687458c7..58e3ad3e4d1ad1ac01b6fc5f85fddb285636e5cf 100644 (file)
@@ -2045,11 +2045,15 @@ do_main_loop(void)
 #ifdef HAVE_SYSTEMD_209
   uint64_t watchdog_delay;
   /* set up systemd watchdog notification. */
-  if (sd_watchdog_enabled(1, &watchdog_delay)) {
+  if (sd_watchdog_enabled(1, &watchdog_delay) > 0) {
     if (! systemd_watchdog_timer) {
       struct timeval watchdog;
-      watchdog.tv_sec = 0;
-      watchdog.tv_usec = watchdog_delay/2;
+      /* The manager will "act on" us if we don't send them a notification
+       * every 'watchdog_delay' microseconds.  So, send notifications twice
+       * that often.  */
+      watchdog_delay /= 2;
+      watchdog.tv_sec = watchdog_delay  / 1000000;
+      watchdog.tv_usec = watchdog_delay % 1000000;
 
       systemd_watchdog_timer = periodic_timer_new(tor_libevent_get_base(),
                                                   &watchdog,