X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Funit.c;h=e3687d473f1e16997900ea80229dc93b839daaee;hb=e025b4c306d4b0895786839ebbb934188edc6e61;hp=057431c8087a7d17b85fd8cb49374a1a6598a966;hpb=ab5c3e3ff172e7dc295d3022170ee6a3be062a3f;p=elogind.git diff --git a/src/unit.c b/src/unit.c index 057431c80..e3687d473 100644 --- a/src/unit.c +++ b/src/unit.c @@ -1741,10 +1741,13 @@ int unit_add_cgroup(Unit *u, CGroupBonding *b) { assert(b->path); - if (!b->controller) + if (!b->controller) { if (!(b->controller = strdup(SYSTEMD_CGROUP_CONTROLLER))) return -ENOMEM; + b->ours = true; + } + /* Ensure this hasn't been added yet */ assert(!b->unit); @@ -1789,6 +1792,7 @@ static char *default_cgroup_path(Unit *u) { int unit_add_cgroup_from_text(Unit *u, const char *name) { char *controller = NULL, *path = NULL; CGroupBonding *b = NULL; + bool ours = false; int r; assert(u); @@ -1797,11 +1801,15 @@ int unit_add_cgroup_from_text(Unit *u, const char *name) { if ((r = cg_split_spec(name, &controller, &path)) < 0) return r; - if (!path) + if (!path) { path = default_cgroup_path(u); + ours = true; + } - if (!controller) + if (!controller) { controller = strdup(SYSTEMD_CGROUP_CONTROLLER); + ours = true; + } if (!path || !controller) { free(path); @@ -1822,7 +1830,8 @@ int unit_add_cgroup_from_text(Unit *u, const char *name) { b->controller = controller; b->path = path; - b->ours = false; + b->ours = ours; + b->essential = streq(controller, SYSTEMD_CGROUP_CONTROLLER); if ((r = unit_add_cgroup(u, b)) < 0) goto fail; @@ -2305,21 +2314,25 @@ void unit_status_printf(Unit *u, const char *format, ...) { } bool unit_need_daemon_reload(Unit *u) { - struct stat st; - assert(u); - if (!u->meta.fragment_path) - return false; + if (u->meta.fragment_path) { + struct stat st; - zero(st); - if (stat(u->meta.fragment_path, &st) < 0) - /* What, cannot access this anymore? */ - return true; + zero(st); + if (stat(u->meta.fragment_path, &st) < 0) + /* What, cannot access this anymore? */ + return true; + + if (u->meta.fragment_mtime > 0 && + timespec_load(&st.st_mtim) != u->meta.fragment_mtime) + return true; + } - return - u->meta.fragment_mtime && - timespec_load(&st.st_mtim) != u->meta.fragment_mtime; + if (UNIT_VTABLE(u)->need_daemon_reload) + return UNIT_VTABLE(u)->need_daemon_reload(u); + + return false; } void unit_reset_failed(Unit *u) {