]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
fix and enable systemd watchdog
authorTomasz Torcz <tomek@pipebreaker.pl>
Fri, 9 Jan 2015 22:42:16 +0000 (23:42 +0100)
committerNick Mathewson <nickm@torproject.org>
Sun, 11 Jan 2015 16:14:32 +0000 (11:14 -0500)
  There were following problems:
  - configure.ac wrongly checked for defined HAVE_SYSTEMD; this
    wasn't working, so the watchdog code was not compiled in.
    Replace library search with explicit version check
  - sd_notify() watchdog call was unsetting NOTIFY_SOCKET from env;
    this means only first "watchdog ping" was delivered, each
    subsequent one did not have socket to be sent to and systemd
    was killing service
  - after those fixes, enable Watchdog in systemd unit with one
    minute intervals

configure.ac
contrib/dist/tor.service.in
src/or/main.c

index 1fd5960366b2c9a4f93641db571647812ab6181a..dedfb7e5bdf21f0f56931219a001da80b01b9ad9 100644 (file)
@@ -136,6 +136,9 @@ fi
 AC_SUBST(TOR_SYSTEMD_CFLAGS)
 AC_SUBST(TOR_SYSTEMD_LIBS)
 
+PKG_CHECK_MODULES(SYSTEMD209, [systemd >= 209],
+    [AC_DEFINE(HAVE_SYSTEMD_209,1,[Have systemd v209 or more])], [])
+
 if test x$enable_systemd = xyes -a x$have_systemd != xyes ; then
     AC_MSG_ERROR([Explicitly requested systemd support, but systemd not found])
 fi
@@ -155,10 +158,6 @@ cpu workers lock up here, so I will disable threads.])
    esac
 fi
 
-ifdef([HAVE_SYSTEMD], [
-AC_SEARCH_LIBS([sd_watchdog_enabled], [systemd-daemon],
-    [AC_DEFINE(HAVE_SYSTEMD_209,1,[Have systemd v209 or more])], [])
-])
 
 case $host in
    *-*-solaris* )
index 607615afa2cf884dfc32306c7310542c6b201cd3..f50075da6f733850522c0001539b86f094d936f8 100644 (file)
@@ -11,6 +11,7 @@ ExecReload = /bin/kill -HUP ${MAINPID}
 KillSignal = SIGINT
 TimeoutSec = 30
 Restart = on-failure
+WatchdogSec = 1m
 LimitNOFILE = 32768
 
 # Hardening
index 1b439041b99089b62259f6a9df956acf7d0fde77..bf4e6db7c1877a1d0462143b98a9e4360639d5d2 100644 (file)
@@ -1776,7 +1776,7 @@ static periodic_timer_t *systemd_watchdog_timer = NULL;
 static void
 systemd_watchdog_callback(periodic_timer_t *timer, void *arg)
 {
-  sd_notify(1, "WATCHDOG=1");
+  sd_notify(0, "WATCHDOG=1");
 }
 #endif