From: Lennart Poettering Date: Wed, 10 Jul 2013 19:17:37 +0000 (+0200) Subject: unit: when deserializing cgroup path add it back into cgroup hashmap X-Git-Tag: v206~158 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=72673e866a83e6aafdbb599eb3eff2617b7dc79d unit: when deserializing cgroup path add it back into cgroup hashmap Also, properly remove cgroup path from hashmap when freeing unit. --- diff --git a/src/core/unit.c b/src/core/unit.c index 70cdd3d94..5bc57e25c 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -433,7 +433,11 @@ void unit_free(Unit *u) { if (u->in_cgroup_queue) LIST_REMOVE(Unit, cgroup_queue, u->manager->cgroup_queue, u); - free(u->cgroup_path); + if (u->cgroup_path) { + hashmap_remove(u->manager->cgroup_unit, u->cgroup_path); + free(u->cgroup_path); + } + free(u->description); strv_free(u->documentation); free(u->fragment_path); @@ -2308,6 +2312,8 @@ int unit_deserialize(Unit *u, FILE *f, FDSet *fds) { free(u->cgroup_path); u->cgroup_path = s; + + hashmap_put(u->manager->cgroup_unit, s, u); continue; }