X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Fscope.c;h=41da3b9378dc2f083fa8d5bf119aadfd783ef826;hb=3f6da75bcef8293382ce2674322f6c50428eb39f;hp=f88addadf34b8fdd39842dff79bfba1193b7f7f1;hpb=6c12b52e19640747e96f89d85422941a23dc6b29;p=elogind.git diff --git a/src/core/scope.c b/src/core/scope.c index f88addadf..41da3b937 100644 --- a/src/core/scope.c +++ b/src/core/scope.c @@ -46,7 +46,7 @@ static void scope_init(Unit *u) { assert(u); assert(u->load_state == UNIT_STUB); - s->timeout_stop_usec = DEFAULT_TIMEOUT_USEC; + s->timeout_stop_usec = u->manager->default_timeout_stop_usec; watch_init(&s->timer_watch); @@ -112,7 +112,7 @@ static int scope_verify(Scope *s) { if (UNIT(s)->load_state != UNIT_LOADED) return 0; - if (set_size(s->pids) <= 0) { + if (set_size(s->pids) <= 0 && UNIT(s)->manager->n_reloading <= 0) { log_error_unit(UNIT(s)->id, "Scope %s has no PIDs. Refusing.", UNIT(s)->id); return -EINVAL; } @@ -239,6 +239,9 @@ static int scope_start(Unit *u) { assert(s); + if (s->state == SCOPE_FAILED) + return -EPERM; + if (s->state == SCOPE_STOP_SIGTERM || s->state == SCOPE_STOP_SIGKILL) return -EAGAIN; @@ -254,7 +257,7 @@ static int scope_start(Unit *u) { return r; } - r = cg_attach_many_with_mask(u->cgroup_mask, u->cgroup_path, s->pids); + r = cg_attach_many_everywhere(u->manager->cgroup_supported, u->cgroup_path, s->pids); if (r < 0) return r; @@ -283,6 +286,17 @@ static int scope_stop(Unit *u) { return 0; } +static void scope_reset_failed(Unit *u) { + Scope *s = SCOPE(u); + + assert(s); + + if (s->state == SCOPE_FAILED) + scope_set_state(s, SCOPE_DEAD); + + s->result = SCOPE_SUCCESS; +} + static int scope_kill(Unit *u, KillWho who, int signo, DBusError *error) { return unit_kill_common(u, who, signo, -1, -1, error); } @@ -403,7 +417,7 @@ _pure_ static const char *scope_sub_state_to_string(Unit *u) { static const char* const scope_state_table[_SCOPE_STATE_MAX] = { [SCOPE_DEAD] = "dead", - [SCOPE_RUNNING] = "active", + [SCOPE_RUNNING] = "running", [SCOPE_STOP_SIGTERM] = "stop-sigterm", [SCOPE_STOP_SIGKILL] = "stop-sigkill", [SCOPE_FAILED] = "failed", @@ -455,6 +469,8 @@ const UnitVTable scope_vtable = { .timer_event = scope_timer_event, + .reset_failed = scope_reset_failed, + .notify_cgroup_empty = scope_notify_cgroup_empty_event, .bus_interface = "org.freedesktop.systemd1.Scope",