dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone
Blob Blame History Raw
From b46e2d4e3b150984bc6e3d74fbbaf215c7b728e3 Mon Sep 17 00:00:00 2001
From: Alexey Tikhonov <atikhono@redhat.com>
Date: Wed, 11 Mar 2020 22:13:42 +0100
Subject: [PATCH] Watchdog: fixes "off-by-one" error
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

'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 <pbrezina@redhat.com>
(cherry picked from commit 653df698a7a04c40df13eb4217c7d598aba8f8f8)
---
 src/util/util_watchdog.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/util/util_watchdog.c b/src/util/util_watchdog.c
index 599b7fc40..ae249c2ca 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);
         }
-- 
2.21.1