X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Funit.c;h=b362fd3b41957385e7e106f2a10bc98e45bc7bce;hb=b12c1e7cf744a5e28db5a29e89377496893c1ab8;hp=a5f8712ae6d1101b358ad092095b4bfa6c002ea5;hpb=398ef8ba0266cca453d90a90b3a2aa1caa44189f;p=elogind.git diff --git a/src/unit.c b/src/unit.c index a5f8712ae..b362fd3b4 100644 --- a/src/unit.c +++ b/src/unit.c @@ -39,6 +39,7 @@ #include "specifier.h" #include "dbus-unit.h" #include "special.h" +#include "cgroup-util.h" const UnitVTable * const unit_vtable[_UNIT_TYPE_MAX] = { [UNIT_SERVICE] = &service_vtable, @@ -970,6 +971,12 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns) { else if (UNIT_IS_ACTIVE_OR_RELOADING(os) && !UNIT_IS_ACTIVE_OR_RELOADING(ns)) u->meta.active_exit_timestamp = ts; + if (ns != os && ns == UNIT_MAINTENANCE) + log_notice("Unit %s entered maintenance state.", u->meta.id); + + if (UNIT_IS_INACTIVE_OR_MAINTENANCE(ns)) + cgroup_bonding_trim_list(u->meta.cgroup_bondings, true); + timer_unit_notify(u, ns); path_unit_notify(u, ns); @@ -1138,14 +1145,14 @@ int unit_watch_pid(Unit *u, pid_t pid) { /* Watch a specific PID. We only support one unit watching * each PID for now. */ - return hashmap_put(u->meta.manager->watch_pids, UINT32_TO_PTR(pid), u); + return hashmap_put(u->meta.manager->watch_pids, LONG_TO_PTR(pid), u); } void unit_unwatch_pid(Unit *u, pid_t pid) { assert(u); assert(pid >= 1); - hashmap_remove_value(u->meta.manager->watch_pids, UINT32_TO_PTR(pid), u); + hashmap_remove_value(u->meta.manager->watch_pids, LONG_TO_PTR(pid), u); } int unit_watch_timer(Unit *u, usec_t delay, Watch *w) { @@ -1592,7 +1599,7 @@ int unit_add_cgroup_from_text(Unit *u, const char *name) { if (n > 0) controller = strndup(name, n); else - controller = strdup(u->meta.manager->cgroup_controller); + controller = strdup(SYSTEMD_CGROUP_CONTROLLER); if (!controller) { r = -ENOMEM; @@ -1641,7 +1648,7 @@ int unit_add_default_cgroup(Unit *u) { if (!(b = new0(CGroupBonding, 1))) return -ENOMEM; - if (!(b->controller = strdup(u->meta.manager->cgroup_controller))) + if (!(b->controller = strdup(SYSTEMD_CGROUP_CONTROLLER))) goto fail; if (!(b->path = default_cgroup_path(u))) @@ -1666,7 +1673,7 @@ fail: CGroupBonding* unit_get_default_cgroup(Unit *u) { assert(u); - return cgroup_bonding_find_list(u->meta.cgroup_bondings, u->meta.manager->cgroup_controller); + return cgroup_bonding_find_list(u->meta.cgroup_bondings, SYSTEMD_CGROUP_CONTROLLER); } int unit_load_related_unit(Unit *u, const char *type, Unit **_found) {