chiark / gitweb /
service: add minimal access control logic for notifcation socket
[elogind.git] / src / unit.c
index c08091942e4728fc5561cccf4216f50a3aadfb40..327444bba4d087f7b76b154506b498061111a4c5 100644 (file)
@@ -38,6 +38,7 @@
 #include "unit-name.h"
 #include "specifier.h"
 #include "dbus-unit.h"
+#include "special.h"
 
 const UnitVTable * const unit_vtable[_UNIT_TYPE_MAX] = {
         [UNIT_SERVICE] = &service_vtable,
@@ -319,10 +320,19 @@ void unit_free(Unit *u) {
 
         bus_unit_send_removed_signal(u);
 
-        /* Detach from next 'bigger' objects */
+        if (u->meta.load_state != UNIT_STUB)
+                if (UNIT_VTABLE(u)->done)
+                        UNIT_VTABLE(u)->done(u);
+
         SET_FOREACH(t, u->meta.names, i)
                 hashmap_remove_value(u->meta.manager->units, t, u);
 
+        if (u->meta.job)
+                job_free(u->meta.job);
+
+        for (d = 0; d < _UNIT_DEPENDENCY_MAX; d++)
+                bidi_set_free(u, u->meta.dependencies[d]);
+
         if (u->meta.type != _UNIT_TYPE_INVALID)
                 LIST_REMOVE(Meta, units_per_type, u->meta.manager->units_per_type[u->meta.type], &u->meta);
 
@@ -340,25 +350,12 @@ void unit_free(Unit *u) {
                 u->meta.manager->n_in_gc_queue--;
         }
 
-        /* Free data and next 'smaller' objects */
-        if (u->meta.job)
-                job_free(u->meta.job);
-
-        if (u->meta.load_state != UNIT_STUB)
-                if (UNIT_VTABLE(u)->done)
-                        UNIT_VTABLE(u)->done(u);
-
         cgroup_bonding_free_list(u->meta.cgroup_bondings);
 
-        for (d = 0; d < _UNIT_DEPENDENCY_MAX; d++)
-                bidi_set_free(u, u->meta.dependencies[d]);
-
         free(u->meta.description);
         free(u->meta.fragment_path);
 
-        while ((t = set_steal_first(u->meta.names)))
-                free(t);
-        set_free(u->meta.names);
+        set_free_free(u->meta.names);
 
         free(u->meta.instance);
 
@@ -404,10 +401,7 @@ static void merge_names(Unit *u, Unit *other) {
 
         complete_move(&u->meta.names, &other->meta.names);
 
-        while ((t = set_steal_first(other->meta.names)))
-                free(t);
-
-        set_free(other->meta.names);
+        set_free_free(other->meta.names);
         other->meta.names = NULL;
         other->meta.id = NULL;