summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <withnall@endlessm.com>2019-06-12 08:23:24 +0100
committerPhilip Withnall <withnall@endlessm.com>2019-07-29 12:13:52 +0100
commit7508f7f273cb2957dbdf7cd8d5d7fe040c80d8e4 (patch)
tree5bc5c887d871b315f633643a1661075cc2c5b576
parent5a70a68fd6568639b1739d4be6130d15cf91a39f (diff)
downloadsystemd-7508f7f273cb2957dbdf7cd8d5d7fe040c80d8e4.tar.gz
scope: Refactor timer handling on coldplug
Factor it out into a helper function which is a bit easier to expand in future. This introduces no functional changes. Signed-off-by: Philip Withnall <withnall@endlessm.com>
-rw-r--r--src/core/scope.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/core/scope.c b/src/core/scope.c
index bb1e60dd11..5303142d09 100644
--- a/src/core/scope.c
+++ b/src/core/scope.c
@@ -197,6 +197,20 @@ static int scope_load(Unit *u) {
return scope_verify(s);
}
+static usec_t scope_coldplug_timeout(Scope *s) {
+ assert(s);
+
+ switch (s->deserialized_state) {
+
+ case SCOPE_STOP_SIGKILL:
+ case SCOPE_STOP_SIGTERM:
+ return usec_add(UNIT(s)->state_change_timestamp.monotonic, s->timeout_stop_usec);
+
+ default:
+ return USEC_INFINITY;
+ }
+}
+
static int scope_coldplug(Unit *u) {
Scope *s = SCOPE(u);
int r;
@@ -207,11 +221,9 @@ static int scope_coldplug(Unit *u) {
if (s->deserialized_state == s->state)
return 0;
- if (IN_SET(s->deserialized_state, SCOPE_STOP_SIGKILL, SCOPE_STOP_SIGTERM)) {
- r = scope_arm_timer(s, usec_add(u->state_change_timestamp.monotonic, s->timeout_stop_usec));
- if (r < 0)
- return r;
- }
+ r = scope_arm_timer(s, scope_coldplug_timeout(s));
+ if (r < 0)
+ return r;
if (!IN_SET(s->deserialized_state, SCOPE_DEAD, SCOPE_FAILED))
(void) unit_enqueue_rewatch_pids(u);