129 lines
5.1 KiB
Diff
129 lines
5.1 KiB
Diff
|
From b2ffdc8da536cd88a305f97517f356e2c5383a52 Mon Sep 17 00:00:00 2001
|
||
|
From: Lennart Poettering <lennart@poettering.net>
|
||
|
Date: Wed, 29 Jan 2014 14:58:04 +0100
|
||
|
Subject: [PATCH 3/3] core: make sure to always go through both SIGTERM and
|
||
|
SIGKILL states of units
|
||
|
|
||
|
Given that we now have KillMode=mixed where SIGTERM might kill a smaller
|
||
|
set than SIGKILL we need to make sure to always go explicitly throught
|
||
|
the SIGKILL state to get the right end result.
|
||
|
---
|
||
|
src/core/mount.c | 8 +++++++-
|
||
|
src/core/scope.c | 4 +++-
|
||
|
src/core/service.c | 10 +++++++---
|
||
|
src/core/socket.c | 6 +++++-
|
||
|
src/core/swap.c | 6 +++++-
|
||
|
5 files changed, 27 insertions(+), 7 deletions(-)
|
||
|
|
||
|
diff --git a/src/core/mount.c b/src/core/mount.c
|
||
|
index 3d46557..e418d09 100644
|
||
|
--- a/src/core/mount.c
|
||
|
+++ b/src/core/mount.c
|
||
|
@@ -854,8 +854,14 @@ static void mount_enter_signal(Mount *m, MountState state, MountResult f) {
|
||
|
goto fail;
|
||
|
|
||
|
mount_set_state(m, state);
|
||
|
- } else if (state == MOUNT_REMOUNTING_SIGTERM || state == MOUNT_REMOUNTING_SIGKILL)
|
||
|
+ } else if (state == MOUNT_REMOUNTING_SIGTERM)
|
||
|
+ mount_enter_signal(m, MOUNT_REMOUNTING_SIGKILL, MOUNT_SUCCESS);
|
||
|
+ else if (state == MOUNT_REMOUNTING_SIGKILL)
|
||
|
mount_enter_mounted(m, MOUNT_SUCCESS);
|
||
|
+ else if (state == MOUNT_MOUNTING_SIGTERM)
|
||
|
+ mount_enter_signal(m, MOUNT_MOUNTING_SIGKILL, MOUNT_SUCCESS);
|
||
|
+ else if (state == MOUNT_UNMOUNTING_SIGTERM)
|
||
|
+ mount_enter_signal(m, MOUNT_UNMOUNTING_SIGKILL, MOUNT_SUCCESS);
|
||
|
else
|
||
|
mount_enter_dead(m, MOUNT_SUCCESS);
|
||
|
|
||
|
diff --git a/src/core/scope.c b/src/core/scope.c
|
||
|
index 50e5dba..3a5c95e 100644
|
||
|
--- a/src/core/scope.c
|
||
|
+++ b/src/core/scope.c
|
||
|
@@ -221,7 +221,9 @@ static void scope_enter_signal(Scope *s, ScopeState state, ScopeResult f) {
|
||
|
}
|
||
|
|
||
|
scope_set_state(s, state);
|
||
|
- } else
|
||
|
+ } else if (state == SCOPE_STOP_SIGTERM)
|
||
|
+ scope_enter_signal(s, SCOPE_STOP_SIGKILL, SCOPE_SUCCESS);
|
||
|
+ else
|
||
|
scope_enter_dead(s, SCOPE_SUCCESS);
|
||
|
|
||
|
return;
|
||
|
diff --git a/src/core/service.c b/src/core/service.c
|
||
|
index e7f03e1..4b481c2 100644
|
||
|
--- a/src/core/service.c
|
||
|
+++ b/src/core/service.c
|
||
|
@@ -1964,10 +1964,9 @@ static void service_enter_stop_post(Service *s, ServiceResult f) {
|
||
|
if (r < 0)
|
||
|
goto fail;
|
||
|
|
||
|
-
|
||
|
service_set_state(s, SERVICE_STOP_POST);
|
||
|
} else
|
||
|
- service_enter_dead(s, SERVICE_SUCCESS, true);
|
||
|
+ service_enter_signal(s, SERVICE_FINAL_SIGTERM, SERVICE_SUCCESS);
|
||
|
|
||
|
return;
|
||
|
|
||
|
@@ -1993,6 +1992,7 @@ static void service_enter_signal(Service *s, ServiceState state, ServiceResult f
|
||
|
s->main_pid,
|
||
|
s->control_pid,
|
||
|
s->main_pid_alien);
|
||
|
+
|
||
|
if (r < 0)
|
||
|
goto fail;
|
||
|
|
||
|
@@ -2005,8 +2005,12 @@ static void service_enter_signal(Service *s, ServiceState state, ServiceResult f
|
||
|
}
|
||
|
|
||
|
service_set_state(s, state);
|
||
|
- } else if (state == SERVICE_STOP_SIGTERM || state == SERVICE_STOP_SIGKILL)
|
||
|
+ } else if (state == SERVICE_STOP_SIGTERM)
|
||
|
+ service_enter_signal(s, SERVICE_STOP_SIGKILL, SERVICE_SUCCESS);
|
||
|
+ else if (state == SERVICE_STOP_SIGKILL)
|
||
|
service_enter_stop_post(s, SERVICE_SUCCESS);
|
||
|
+ else if (state == SERVICE_FINAL_SIGTERM)
|
||
|
+ service_enter_signal(s, SERVICE_FINAL_SIGKILL, SERVICE_SUCCESS);
|
||
|
else
|
||
|
service_enter_dead(s, SERVICE_SUCCESS, true);
|
||
|
|
||
|
diff --git a/src/core/socket.c b/src/core/socket.c
|
||
|
index 6c0ac1a..831876f 100644
|
||
|
--- a/src/core/socket.c
|
||
|
+++ b/src/core/socket.c
|
||
|
@@ -1298,8 +1298,12 @@ static void socket_enter_signal(Socket *s, SocketState state, SocketResult f) {
|
||
|
goto fail;
|
||
|
|
||
|
socket_set_state(s, state);
|
||
|
- } else if (state == SOCKET_STOP_PRE_SIGTERM || state == SOCKET_STOP_PRE_SIGKILL)
|
||
|
+ } else if (state == SOCKET_STOP_PRE_SIGTERM)
|
||
|
+ socket_enter_signal(s, SOCKET_STOP_PRE_SIGKILL, SOCKET_SUCCESS);
|
||
|
+ else if (state == SOCKET_STOP_PRE_SIGKILL)
|
||
|
socket_enter_stop_post(s, SOCKET_SUCCESS);
|
||
|
+ else if (state == SOCKET_FINAL_SIGTERM)
|
||
|
+ socket_enter_signal(s, SOCKET_FINAL_SIGKILL, SOCKET_SUCCESS);
|
||
|
else
|
||
|
socket_enter_dead(s, SOCKET_SUCCESS);
|
||
|
|
||
|
diff --git a/src/core/swap.c b/src/core/swap.c
|
||
|
index a68ab7c..8886fe8 100644
|
||
|
--- a/src/core/swap.c
|
||
|
+++ b/src/core/swap.c
|
||
|
@@ -655,7 +655,11 @@ static void swap_enter_signal(Swap *s, SwapState state, SwapResult f) {
|
||
|
goto fail;
|
||
|
|
||
|
swap_set_state(s, state);
|
||
|
- } else
|
||
|
+ } else if (state == SWAP_ACTIVATING_SIGTERM)
|
||
|
+ swap_enter_signal(s, SWAP_ACTIVATING_SIGKILL, SWAP_SUCCESS);
|
||
|
+ else if (state == SWAP_DEACTIVATING_SIGTERM)
|
||
|
+ swap_enter_signal(s, SWAP_DEACTIVATING_SIGKILL, SWAP_SUCCESS);
|
||
|
+ else
|
||
|
swap_enter_dead(s, SWAP_SUCCESS);
|
||
|
|
||
|
return;
|
||
|
--
|
||
|
1.8.4
|
||
|
|