chiark / gitweb /
Make sure that keys are properly removed from hashmap
[elogind.git] / src / core / unit.c
index 6ac359e31b755daadb280abef5319c5c24002b1c..c4ed9233731a88756e15b855b338bfdaa11a3a12 100644 (file)
@@ -2488,10 +2488,18 @@ int unit_deserialize(Unit *u, FILE *f, FDSet *fds) {
                         if (!s)
                                 return -ENOMEM;
 
-                        free(u->cgroup_path);
-                        u->cgroup_path = s;
+                        if (u->cgroup_path) {
+                                void *p;
+
+                                p = hashmap_remove(u->manager->cgroup_unit, u->cgroup_path);
+                                log_info("Removing cgroup_path %s from hashmap (%p)",
+                                         u->cgroup_path, p);
+                                free(u->cgroup_path);
+                        }
 
+                        u->cgroup_path = s;
                         assert(hashmap_put(u->manager->cgroup_unit, s, u) == 1);
+
                         continue;
                 }