diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-12-23 11:27:16 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-12-23 11:27:18 -0500 |
commit | 2f46e5e7558ca3b7dab16fb970d16c1a3dfd190c (patch) | |
tree | 6cbfbd103fe6dc0363819e760cdde2f4e76660ba | |
parent | 29ac883606d6d5ebfdcc2efceb2b4b60ee6a8916 (diff) | |
download | tor-2f46e5e7558ca3b7dab16fb970d16c1a3dfd190c.tar.gz tor-2f46e5e7558ca3b7dab16fb970d16c1a3dfd190c.zip |
Adjust systemd watchdog support
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.
-rw-r--r-- | src/or/main.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/or/main.c b/src/or/main.c index 5a17212da6..58e3ad3e4d 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -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, |