X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Funit.c;h=a7e6714c4508a5855d8d1158ab780fa3de06e714;hb=e0fa621b8b52da4d95bf5918eb998c9166e4bc7c;hp=bfb1dd644ebb62013d7f98cd23e112b9998f504b;hpb=d686d8a97bd7945af0a61504392d01a3167b576f;p=elogind.git diff --git a/src/unit.c b/src/unit.c index bfb1dd644..a7e6714c4 100644 --- a/src/unit.c +++ b/src/unit.c @@ -1067,7 +1067,7 @@ static void retroactively_stop_dependencies(Unit *u) { unit_check_unneeded(other); } -void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns) { +void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_success) { dual_timestamp ts; bool unexpected; @@ -1134,7 +1134,7 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns) { if (u->meta.job->state == JOB_RUNNING) { if (ns == UNIT_ACTIVE) - job_finish_and_invalidate(u->meta.job, true); + job_finish_and_invalidate(u->meta.job, reload_success); else if (ns != UNIT_ACTIVATING && ns != UNIT_RELOADING) { unexpected = true; @@ -1194,7 +1194,7 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns) { /* The bus just might have become available, * hence try to connect to it, if we aren't * yet connected. */ - bus_init(u->meta.manager); + bus_init(u->meta.manager, true); if (unit_has_name(u, SPECIAL_SYSLOG_SERVICE)) /* The syslog daemon just might have become @@ -1785,55 +1785,61 @@ fail: return r; } -int unit_add_default_cgroups(Unit *u) { +static int unit_add_one_default_cgroup(Unit *u, const char *controller) { CGroupBonding *b = NULL; int r = -ENOMEM; - const char * const default_controllers[] = { - SYSTEMD_CGROUP_CONTROLLER, - "cpu", - NULL - }; - const char * const*c; assert(u); - /* Adds in the default cgroups, if it wasn't specified yet */ - - STRV_FOREACH(c, default_controllers) { - - if (cgroup_bonding_find_list(u->meta.cgroup_bondings, *c)) - continue; + if (!controller) + controller = SYSTEMD_CGROUP_CONTROLLER; - if (!(b = new0(CGroupBonding, 1))) - return -ENOMEM; + if (cgroup_bonding_find_list(u->meta.cgroup_bondings, controller)) + return 0; - if (!(b->path = default_cgroup_path(u))) - goto fail; + if (!(b = new0(CGroupBonding, 1))) + return -ENOMEM; - if (!(b->controller = strdup(*c))) - goto fail; + if (!(b->controller = strdup(controller))) + goto fail; - b->ours = true; - b->essential = c == default_controllers; /* the first one is essential */ + if (!(b->path = default_cgroup_path(u))) + goto fail; - if ((r = unit_add_cgroup(u, b)) < 0) - goto fail; + b->ours = true; + b->essential = streq(controller, SYSTEMD_CGROUP_CONTROLLER); - b = NULL; - } + if ((r = unit_add_cgroup(u, b)) < 0) + goto fail; return 0; fail: - if (b) { - free(b->path); - free(b->controller); - free(b); - } + free(b->path); + free(b->controller); + free(b); return r; } +int unit_add_default_cgroups(Unit *u) { + char **c; + int r; + assert(u); + + /* Adds in the default cgroups, if they weren't specified + * otherwise. */ + + if ((r = unit_add_one_default_cgroup(u, NULL)) < 0) + return r; + + STRV_FOREACH(c, u->meta.manager->default_controllers) + if ((r = unit_add_one_default_cgroup(u, *c)) < 0) + return r; + + return 0; +} + CGroupBonding* unit_get_default_cgroup(Unit *u) { assert(u);