X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=src%2Fmachine%2Fmachined.c;h=ace2131c2deaa512bb9960d73277dd2093b0fe3c;hb=269e4d2d6b75329ae39a71ebe2c14500e03cda95;hp=a2e7a3024051e40b7c57cb60c8d7e43124cc124f;hpb=27b99f29123e34d9ab378e831a98b14ea407a34f;p=thirdparty%2Fsystemd.git diff --git a/src/machine/machined.c b/src/machine/machined.c index a2e7a302405..ace2131c2de 100644 --- a/src/machine/machined.c +++ b/src/machine/machined.c @@ -2,13 +2,15 @@ #include #include +#include +#include #include #include "sd-daemon.h" #include "alloc-util.h" #include "bus-error.h" -#include "bus-util.h" +#include "bus-polkit.h" #include "cgroup-util.h" #include "dirent-util.h" #include "fd-util.h" @@ -25,6 +27,8 @@ static Manager* manager_unref(Manager *m); DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_unref); +DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(machine_hash_ops, char, string_hash_func, string_compare_func, Machine, machine_free); + static int manager_new(Manager **ret) { _cleanup_(manager_unrefp) Manager *m = NULL; int r; @@ -35,7 +39,7 @@ static int manager_new(Manager **ret) { if (!m) return -ENOMEM; - m->machines = hashmap_new(&string_hash_ops); + m->machines = hashmap_new(&machine_hash_ops); m->machine_units = hashmap_new(&string_hash_ops); m->machine_leaders = hashmap_new(NULL); @@ -61,8 +65,6 @@ static int manager_new(Manager **ret) { } static Manager* manager_unref(Manager *m) { - Machine *machine; - if (!m) return NULL; @@ -71,20 +73,17 @@ static Manager* manager_unref(Manager *m) { assert(m->n_operations == 0); - while ((machine = hashmap_first(m->machines))) - machine_free(machine); - - hashmap_free(m->machines); + hashmap_free(m->machines); /* This will free all machines, so that the machine_units/machine_leaders is empty */ hashmap_free(m->machine_units); hashmap_free(m->machine_leaders); - - hashmap_free_with_destructor(m->image_cache, image_unref); + hashmap_free(m->image_cache); sd_event_source_unref(m->image_cache_defer_event); + sd_event_source_unref(m->nscd_cache_flush_event); bus_verify_polkit_async_registry_free(m->polkit_registry); - sd_bus_unref(m->bus); + sd_bus_flush_close_unref(m->bus); sd_event_unref(m->event); return mfree(m); @@ -350,10 +349,8 @@ static int run(int argc, char *argv[]) { _cleanup_(manager_unrefp) Manager *m = NULL; int r; - log_set_target(LOG_TARGET_AUTO); log_set_facility(LOG_AUTH); - log_parse_environment(); - log_open(); + log_setup_service(); umask(0022);