dm0 / rpms / systemd

Forked from rpms/systemd 5 years ago
Clone
46a556f
From 05e3a4c68cf81d8feaedaec233183a6438942dfb Mon Sep 17 00:00:00 2001
46a556f
From: Michael Olbrich <m.olbrich@pengutronix.de>
46a556f
Date: Sun, 19 May 2013 12:10:55 +0200
46a556f
Subject: [PATCH] service: kill processes with SIGKILL on watchdog failure
46a556f
46a556f
Just calling service_enter_dead() does not kill any processes.
46a556f
As a result, the old process may still be running when the new one is
46a556f
started.
46a556f
46a556f
After a watchdog failure the service is in an undefined state.
46a556f
Using the normal shutdown mechanism makes no sense. Instead all processes
46a556f
are just killed and the service can try to restart.
46a556f
---
46a556f
 src/core/service.c | 6 ++----
46a556f
 1 file changed, 2 insertions(+), 4 deletions(-)
46a556f
46a556f
diff --git a/src/core/service.c b/src/core/service.c
46a556f
index 9682fc3..0297eb5 100644
46a556f
--- a/src/core/service.c
46a556f
+++ b/src/core/service.c
46a556f
@@ -235,7 +235,7 @@ static void service_stop_watchdog(Service *s) {
46a556f
         s->watchdog_timestamp.monotonic = 0;
46a556f
 }
46a556f
 
46a556f
-static void service_enter_dead(Service *s, ServiceResult f, bool allow_restart);
46a556f
+static void service_enter_signal(Service *s, ServiceState state, ServiceResult f);
46a556f
 
46a556f
 static void service_handle_watchdog(Service *s) {
46a556f
         usec_t offset;
46a556f
@@ -249,7 +249,7 @@ static void service_handle_watchdog(Service *s) {
46a556f
         offset = now(CLOCK_MONOTONIC) - s->watchdog_timestamp.monotonic;
46a556f
         if (offset >= s->watchdog_usec) {
46a556f
                 log_error_unit(UNIT(s)->id, "%s watchdog timeout!", UNIT(s)->id);
46a556f
-                service_enter_dead(s, SERVICE_FAILURE_WATCHDOG, true);
46a556f
+                service_enter_signal(s, SERVICE_FINAL_SIGKILL, SERVICE_FAILURE_WATCHDOG);
46a556f
                 return;
46a556f
         }
46a556f
 
46a556f
@@ -1952,8 +1952,6 @@ fail:
46a556f
         service_enter_dead(s, SERVICE_FAILURE_RESOURCES, false);
46a556f
 }
46a556f
 
46a556f
-static void service_enter_signal(Service *s, ServiceState state, ServiceResult f);
46a556f
-
46a556f
 static void service_enter_stop_post(Service *s, ServiceResult f) {
46a556f
         int r;
46a556f
         assert(s);