diff options
author | Tom Gundersen <teg@jklm.no> | 2015-09-01 19:48:04 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2015-09-01 19:48:04 +0200 |
commit | fc94c3260549c12892461be031c4b9dc122ca1ef (patch) | |
tree | 3b9bf7eccf1690daa57da5419d29554175605c20 /src/core/service.c | |
parent | 332929623af07716530fb0d0a30e792b564ea486 (diff) | |
parent | d06673212e7672da44d5147d1d393278d9b1b478 (diff) |
Merge pull request #1111 from poettering/more-cgroup-fixes
More cgroup fixes
Diffstat (limited to 'src/core/service.c')
-rw-r--r-- | src/core/service.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/core/service.c b/src/core/service.c index 3c4232417d..5a0a3aa867 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -1269,7 +1269,7 @@ static int cgroup_good(Service *s) { if (!UNIT(s)->cgroup_path) return 0; - r = cg_is_empty_recursive(SYSTEMD_CGROUP_CONTROLLER, UNIT(s)->cgroup_path, true); + r = cg_is_empty_recursive(SYSTEMD_CGROUP_CONTROLLER, UNIT(s)->cgroup_path); if (r < 0) return r; @@ -1520,18 +1520,33 @@ fail: service_enter_signal(s, SERVICE_STOP_SIGTERM, SERVICE_FAILURE_RESOURCES); } +static bool service_good(Service *s) { + int main_pid_ok; + assert(s); + + if (s->type == SERVICE_DBUS && !s->bus_name_good) + return false; + + main_pid_ok = main_pid_good(s); + if (main_pid_ok > 0) /* It's alive */ + return true; + if (main_pid_ok == 0) /* It's dead */ + return false; + + /* OK, we don't know anything about the main PID, maybe + * because there is none. Let's check the control group + * instead. */ + + return cgroup_good(s) != 0; +} + static void service_enter_running(Service *s, ServiceResult f) { - int main_pid_ok, cgroup_ok; assert(s); if (f != SERVICE_SUCCESS) s->result = f; - main_pid_ok = main_pid_good(s); - cgroup_ok = cgroup_good(s); - - if ((main_pid_ok > 0 || (main_pid_ok < 0 && cgroup_ok != 0)) && - (s->bus_name_good || s->type != SERVICE_DBUS)) { + if (service_good(s)) { /* If there are any queued up sd_notify() * notifications, process them now */ |