From 653df698a7a04c40df13eb4217c7d598aba8f8f8 Mon Sep 17 00:00:00 2001 From: Alexey Tikhonov Date: Mar 18 2020 12:24:26 +0000 Subject: Watchdog: fixes "off-by-one" error 'man sssd.conf': timeout: "Note that after three missed heartbeats the process will terminate itself." But implementation was: ``` \#define WATCHDOG_MAX_TICKS 3 ... if (__sync_add_and_fetch(&watchdog_ctx.ticks, 1) > WATCHDOG_MAX_TICKS) { ... _exit(1); ``` -- since after reset ticks start from 0 effectively this was 4 heartbeats. Fixed to match man page. Resolves: https://pagure.io/SSSD/sssd/issue/4169 Reviewed-by: Pavel Březina --- diff --git a/src/util/util_watchdog.c b/src/util/util_watchdog.c index 38c2482..a82014c 100644 --- a/src/util/util_watchdog.c +++ b/src/util/util_watchdog.c @@ -71,7 +71,7 @@ static void watchdog_handler(int sig) watchdog_detect_timeshift(); /* if a pre-defined number of ticks passed by kills itself */ - if (__sync_add_and_fetch(&watchdog_ctx.ticks, 1) > WATCHDOG_MAX_TICKS) { + if (__sync_add_and_fetch(&watchdog_ctx.ticks, 1) >= WATCHDOG_MAX_TICKS) { if (getpid() == getpgrp()) { kill(-getpgrp(), SIGTERM); }