summaryrefslogtreecommitdiff
path: root/src/core/scope.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-01-31 17:45:13 +0100
committerLennart Poettering <lennart@poettering.net>2014-01-31 17:48:36 +0100
commit2d4a39e759c4ab846ad8a546abeddd40bc8d736e (patch)
tree6076c82b7c28bc2f80570b72427cc27a2ed28357 /src/core/scope.c
parentfb818b2ea194ec182aa3e776d38883dc615910a1 (diff)
core: introduce new stop protocol for unit scopes
By specifiy a Controller property when creating the scope a client can specify a bus name that will be notified with a RequestStop bus signal when the scope has been asked to shut down, instead of sending SIGTERM to the scope processes themselves. https://bugzilla.redhat.com/show_bug.cgi?id=1032695
Diffstat (limited to 'src/core/scope.c')
-rw-r--r--src/core/scope.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/core/scope.c b/src/core/scope.c
index 5beb4f80c4..0c1d17e68c 100644
--- a/src/core/scope.c
+++ b/src/core/scope.c
@@ -64,6 +64,8 @@ static void scope_done(Unit *u) {
cgroup_context_done(&s->cgroup_context);
+ free(s->controller);
+
set_free(s->pids);
s->pids = NULL;
@@ -217,6 +219,7 @@ static void scope_enter_dead(Scope *s, ScopeResult f) {
}
static void scope_enter_signal(Scope *s, ScopeState state, ScopeResult f) {
+ bool skip_signal = false;
int r;
assert(s);
@@ -224,13 +227,22 @@ static void scope_enter_signal(Scope *s, ScopeState state, ScopeResult f) {
if (f != SCOPE_SUCCESS)
s->result = f;
- r = unit_kill_context(
- UNIT(s),
- &s->kill_context,
- state != SCOPE_STOP_SIGTERM,
- -1, -1, false);
- if (r < 0)
- goto fail;
+ /* If we have a controller set let's ask the controller nicely
+ * to terminate the scope, instead of us going directly into
+ * SIGTERM beserk mode */
+ if (state == SCOPE_STOP_SIGTERM)
+ skip_signal = bus_scope_send_request_stop(s) > 0;
+
+ if (!skip_signal) {
+ r = unit_kill_context(
+ UNIT(s),
+ &s->kill_context,
+ state != SCOPE_STOP_SIGTERM,
+ -1, -1, false);
+ if (r < 0)
+ goto fail;
+ } else
+ r = 1;
if (r > 0) {
r = scope_arm_timer(s);