Blame SOURCES/0004-util-watchdog-fixed-watchdog-implementation.patch

0d441c
From 2c13d8bd00f1e8ff30e9fc81f183f6450303ac30 Mon Sep 17 00:00:00 2001
0d441c
From: Alexey Tikhonov <atikhono@redhat.com>
0d441c
Date: Wed, 11 Dec 2019 18:42:49 +0100
0d441c
Subject: [PATCH] util/watchdog: fixed watchdog implementation
0d441c
0d441c
In case watchdog detected locked process and this process was parent
0d441c
process it just sent SIGTERM to the whole group of processes, including
0d441c
itself.
0d441c
This handling was wrong: generic `server_setup()` installs custom
0d441c
libtevent handler for SIGTERM signal so this signal is only processed
0d441c
in the context of tevent mainloop. But if tevent mainloop is stuck
0d441c
(exactly the case that triggers WD) then event is not processed
0d441c
and this made watchdog useless.
0d441c
`watchdog_handler()` and `watchdog_detect_timeshift()` were amended to do
0d441c
unconditional `_exit()` after optionally sending a signal to the group.
0d441c
0d441c
Resolves: https://pagure.io/SSSD/sssd/issue/4089
0d441c
0d441c
Reviewed-by: Sumit Bose <sbose@redhat.com>
0d441c
---
0d441c
 src/util/util_watchdog.c | 6 ++----
0d441c
 1 file changed, 2 insertions(+), 4 deletions(-)
0d441c
0d441c
diff --git a/src/util/util_watchdog.c b/src/util/util_watchdog.c
0d441c
index a07275b19..38c248271 100644
0d441c
--- a/src/util/util_watchdog.c
0d441c
+++ b/src/util/util_watchdog.c
0d441c
@@ -54,9 +54,8 @@ static void watchdog_detect_timeshift(void)
0d441c
         if (write(watchdog_ctx.pipefd[1], "1", 1) != 1) {
0d441c
             if (getpid() == getpgrp()) {
0d441c
                 kill(-getpgrp(), SIGTERM);
0d441c
-            } else {
0d441c
-                _exit(1);
0d441c
             }
0d441c
+            _exit(1);
0d441c
         }
0d441c
     }
0d441c
 }
0d441c
@@ -75,9 +74,8 @@ static void watchdog_handler(int sig)
0d441c
     if (__sync_add_and_fetch(&watchdog_ctx.ticks, 1) > WATCHDOG_MAX_TICKS) {
0d441c
         if (getpid() == getpgrp()) {
0d441c
             kill(-getpgrp(), SIGTERM);
0d441c
-        } else {
0d441c
-            _exit(1);
0d441c
         }
0d441c
+        _exit(1);
0d441c
     }
0d441c
 }
0d441c
 
0d441c
-- 
0d441c
2.20.1
0d441c