Blame SOURCES/0016-Watchdog-fixes-off-by-one-error.patch

836b22
From b46e2d4e3b150984bc6e3d74fbbaf215c7b728e3 Mon Sep 17 00:00:00 2001
836b22
From: Alexey Tikhonov <atikhono@redhat.com>
836b22
Date: Wed, 11 Mar 2020 22:13:42 +0100
836b22
Subject: [PATCH] Watchdog: fixes "off-by-one" error
836b22
MIME-Version: 1.0
836b22
Content-Type: text/plain; charset=UTF-8
836b22
Content-Transfer-Encoding: 8bit
836b22
836b22
'man sssd.conf': timeout: "Note that after three missed heartbeats
836b22
the process will terminate itself."
836b22
836b22
But implementation was:
836b22
```
836b22
\#define WATCHDOG_MAX_TICKS 3
836b22
...
836b22
    if (__sync_add_and_fetch(&watchdog_ctx.ticks, 1) > WATCHDOG_MAX_TICKS) {
836b22
        ...
836b22
        _exit(1);
836b22
```
836b22
  -- since after reset ticks start from 0 effectively this was 4 heartbeats.
836b22
836b22
Fixed to match man page.
836b22
836b22
Resolves: https://pagure.io/SSSD/sssd/issue/4169
836b22
836b22
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
836b22
(cherry picked from commit 653df698a7a04c40df13eb4217c7d598aba8f8f8)
836b22
---
836b22
 src/util/util_watchdog.c | 2 +-
836b22
 1 file changed, 1 insertion(+), 1 deletion(-)
836b22
836b22
diff --git a/src/util/util_watchdog.c b/src/util/util_watchdog.c
836b22
index 599b7fc40..ae249c2ca 100644
836b22
--- a/src/util/util_watchdog.c
836b22
+++ b/src/util/util_watchdog.c
836b22
@@ -71,7 +71,7 @@ static void watchdog_handler(int sig)
836b22
     watchdog_detect_timeshift();
836b22
 
836b22
     /* if a pre-defined number of ticks passed by kills itself */
836b22
-    if (__sync_add_and_fetch(&watchdog_ctx.ticks, 1) > WATCHDOG_MAX_TICKS) {
836b22
+    if (__sync_add_and_fetch(&watchdog_ctx.ticks, 1) >= WATCHDOG_MAX_TICKS) {
836b22
         if (getpid() == getpgrp()) {
836b22
             kill(-getpgrp(), SIGTERM);
836b22
         }
836b22
-- 
836b22
2.21.1
836b22