chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
cgroup: compare fs paths with path_equal() rather than streq()
[elogind.git]
/
src
/
core
/
cgroup.c
diff --git
a/src/core/cgroup.c
b/src/core/cgroup.c
index 5a1c3adacd19af3f8ff2c67ebcb98ea7ab2e53cd..3eeb47575424f3c853594d122df5e2fe74ee6273 100644
(file)
--- a/
src/core/cgroup.c
+++ b/
src/core/cgroup.c
@@
-382,6
+382,7
@@
static CGroupControllerMask unit_get_siblings_mask(Unit *u) {
static int unit_create_cgroups(Unit *u, CGroupControllerMask mask) {
char *path = NULL;
int r;
static int unit_create_cgroups(Unit *u, CGroupControllerMask mask) {
char *path = NULL;
int r;
+ bool is_in_hash = false;
assert(u);
assert(u);
@@
-390,8
+391,14
@@
static int unit_create_cgroups(Unit *u, CGroupControllerMask mask) {
return -ENOMEM;
r = hashmap_put(u->manager->cgroup_unit, path, u);
return -ENOMEM;
r = hashmap_put(u->manager->cgroup_unit, path, u);
- if (r < 0)
+ if (r == 0)
+ is_in_hash = true;
+
+ if (r < 0) {
+ free(path);
+ log_error("cgroup %s exists already: %s", path, strerror(-r));
return r;
return r;
+ }
/* First, create our own group */
r = cg_create_with_mask(mask, path);
/* First, create our own group */
r = cg_create_with_mask(mask, path);
@@
-405,9
+412,12
@@
static int unit_create_cgroups(Unit *u, CGroupControllerMask mask) {
log_error("Failed to migrate cgroup %s: %s", path, strerror(-r));
}
log_error("Failed to migrate cgroup %s: %s", path, strerror(-r));
}
- /* And remember the new data */
- free(u->cgroup_path);
- u->cgroup_path = path;
+ if (!is_in_hash) {
+ /* And remember the new data */
+ free(u->cgroup_path);
+ u->cgroup_path = path;
+ }
+
u->cgroup_realized = true;
u->cgroup_mask = mask;
u->cgroup_realized = true;
u->cgroup_mask = mask;