mirror of
https://github.com/systemd/systemd.git
synced 2024-11-07 09:56:51 +03:00
unit: consider all cgroups in the name=systemd hierarchy, even when the user has specified an explicit path in it
This commit is contained in:
parent
f284f69a7b
commit
e025b4c306
17
src/unit.c
17
src/unit.c
@ -1741,10 +1741,13 @@ int unit_add_cgroup(Unit *u, CGroupBonding *b) {
|
|||||||
|
|
||||||
assert(b->path);
|
assert(b->path);
|
||||||
|
|
||||||
if (!b->controller)
|
if (!b->controller) {
|
||||||
if (!(b->controller = strdup(SYSTEMD_CGROUP_CONTROLLER)))
|
if (!(b->controller = strdup(SYSTEMD_CGROUP_CONTROLLER)))
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
b->ours = true;
|
||||||
|
}
|
||||||
|
|
||||||
/* Ensure this hasn't been added yet */
|
/* Ensure this hasn't been added yet */
|
||||||
assert(!b->unit);
|
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) {
|
int unit_add_cgroup_from_text(Unit *u, const char *name) {
|
||||||
char *controller = NULL, *path = NULL;
|
char *controller = NULL, *path = NULL;
|
||||||
CGroupBonding *b = NULL;
|
CGroupBonding *b = NULL;
|
||||||
|
bool ours = false;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(u);
|
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)
|
if ((r = cg_split_spec(name, &controller, &path)) < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
if (!path)
|
if (!path) {
|
||||||
path = default_cgroup_path(u);
|
path = default_cgroup_path(u);
|
||||||
|
ours = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!controller)
|
if (!controller) {
|
||||||
controller = strdup(SYSTEMD_CGROUP_CONTROLLER);
|
controller = strdup(SYSTEMD_CGROUP_CONTROLLER);
|
||||||
|
ours = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!path || !controller) {
|
if (!path || !controller) {
|
||||||
free(path);
|
free(path);
|
||||||
@ -1822,7 +1830,8 @@ int unit_add_cgroup_from_text(Unit *u, const char *name) {
|
|||||||
|
|
||||||
b->controller = controller;
|
b->controller = controller;
|
||||||
b->path = path;
|
b->path = path;
|
||||||
b->ours = false;
|
b->ours = ours;
|
||||||
|
b->essential = streq(controller, SYSTEMD_CGROUP_CONTROLLER);
|
||||||
|
|
||||||
if ((r = unit_add_cgroup(u, b)) < 0)
|
if ((r = unit_add_cgroup(u, b)) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
Loading…
Reference in New Issue
Block a user