systemd/0020-Various-simplification...

71 lines
2.6 KiB
Diff

From 2f38e2f3ceaf753979a63a7dcec601fc6c811b11 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Tue, 15 Nov 2016 15:01:40 -0500
Subject: [PATCH] Various simplifications
---
src/core/scope.c | 8 +++++---
src/core/unit.c | 11 +++++------
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/core/scope.c b/src/core/scope.c
index b45e238974..caed476065 100644
--- a/src/core/scope.c
+++ b/src/core/scope.c
@@ -244,7 +244,9 @@ static void scope_enter_signal(Scope *s, ScopeState state, ScopeResult f) {
if (state == SCOPE_STOP_SIGTERM)
skip_signal = bus_scope_send_request_stop(s) > 0;
- if (!skip_signal) {
+ if (skip_signal)
+ r = 1; /* wait */
+ else {
r = unit_kill_context(
UNIT(s),
&s->kill_context,
@@ -254,8 +256,8 @@ static void scope_enter_signal(Scope *s, ScopeState state, ScopeResult f) {
-1, -1, false);
if (r < 0)
goto fail;
- } else
- r = 1;
+ }
+ log_unit_debug(UNIT(s), "Killing unit %s: ret=%d", UNIT(s)->id, r);
if (r > 0) {
r = scope_arm_timer(s, usec_add(now(CLOCK_MONOTONIC), s->timeout_stop_usec));
diff --git a/src/core/unit.c b/src/core/unit.c
index 4934a0e56f..6726ce0749 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -3558,14 +3558,14 @@ int unit_kill_context(
bool main_pid_alien) {
bool wait_for_exit = false, send_sighup;
- cg_kill_log_func_t log_func;
+ cg_kill_log_func_t log_func = NULL;
int sig, r;
assert(u);
assert(c);
- /* Kill the processes belonging to this unit, in preparation for shutting the unit down. Returns > 0 if we
- * killed something worth waiting for, 0 otherwise. */
+ /* Kill the processes belonging to this unit, in preparation for shutting the unit down.
+ * Returns > 0 if we killed something worth waiting for, 0 otherwise. */
if (c->kill_mode == KILL_NONE)
return 0;
@@ -3577,9 +3577,8 @@ int unit_kill_context(
IN_SET(k, KILL_TERMINATE, KILL_TERMINATE_AND_LOG) &&
sig != SIGHUP;
- log_func =
- k != KILL_TERMINATE ||
- IN_SET(sig, SIGKILL, SIGABRT) ? log_kill : NULL;
+ if (k != KILL_TERMINATE || IN_SET(sig, SIGKILL, SIGABRT))
+ log_func = log_kill;
if (main_pid > 0) {
if (log_func)