Ticket #14141: 0003-fix-and-enable-systemd-watchdog.patch

File 0003-fix-and-enable-systemd-watchdog.patch, 2.3 KB (added by tomek@…, 5 years ago)
  • configure.ac

    From 45dfc6d2c14f055f6ecba2114e92359b4da2ffdc Mon Sep 17 00:00:00 2001
    From: Tomasz Torcz <tomek@pipebreaker.pl>
    Date: Fri, 9 Jan 2015 23:42:16 +0100
    Subject: [PATCH 3/3]   fix and enable systemd watchdog
    
      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                | 7 +++----
     contrib/dist/tor.service.in | 1 +
     src/or/main.c               | 2 +-
     3 files changed, 5 insertions(+), 5 deletions(-)
    
    diff --git a/configure.ac b/configure.ac
    index 2c92a6c..6c720e5 100644
    a b if test x$have_systemd = xyes; then 
    135135fi
    136136AC_SUBST(TOR_SYSTEMD_LIBS)
    137137
     138PKG_CHECK_MODULES(SYSTEMD209, [systemd >= 209],
     139    [AC_DEFINE(HAVE_SYSTEMD_209,1,[Have systemd v209 or more])], [])
     140
    138141if test x$enable_systemd = xyes -a x$have_systemd != xyes ; then
    139142    AC_MSG_ERROR([Explicitly requested systemd support, but systemd not found])
    140143fi
    cpu workers lock up here, so I will disable threads.]) 
    154157   esac
    155158fi
    156159
    157 ifdef([HAVE_SYSTEMD], [
    158 AC_SEARCH_LIBS([sd_watchdog_enabled], [systemd-daemon],
    159     [AC_DEFINE(HAVE_SYSTEMD_209,1,[Have systemd v209 or more])], [])
    160 ])
    161160
    162161case $host in
    163162   *-*-solaris* )
  • contrib/dist/tor.service.in

    diff --git a/contrib/dist/tor.service.in b/contrib/dist/tor.service.in
    index 607615a..f50075d 100644
    a b ExecReload = /bin/kill -HUP ${MAINPID} 
    1111KillSignal = SIGINT
    1212TimeoutSec = 30
    1313Restart = on-failure
     14WatchdogSec = 1m
    1415LimitNOFILE = 32768
    1516
    1617# Hardening
  • src/or/main.c

    diff --git a/src/or/main.c b/src/or/main.c
    index 1b43904..bf4e6db 100644
    a b static periodic_timer_t *systemd_watchdog_timer = NULL; 
    17761776static void
    17771777systemd_watchdog_callback(periodic_timer_t *timer, void *arg)
    17781778{
    1779   sd_notify(1, "WATCHDOG=1");
     1779  sd_notify(0, "WATCHDOG=1");
    17801780}
    17811781#endif
    17821782