diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-04-28 21:17:35 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-04-28 21:34:23 +0200 |
commit | 9b420b3cfb8b93daf50e4cdbc92b05f2209ef893 (patch) | |
tree | 0077cd838eeb972c8c33071a85c17e49c02d2eb2 /src/machine/machine.c | |
parent | bus-util: drop redundant bus argument from bus_message_map_all_properties() a... (diff) | |
download | systemd-9b420b3cfb8b93daf50e4cdbc92b05f2209ef893.tar.xz systemd-9b420b3cfb8b93daf50e4cdbc92b05f2209ef893.zip |
machined: make sure to track machine unit states properly
If a unit is stopped for a moment, we need to invalidate our knowledge
of it, otherwise we might be confused by automatic restarts
This makes reboots for nspawn containers run as service work correctly.
https://bugs.freedesktop.org/show_bug.cgi?id=87428
Diffstat (limited to 'src/machine/machine.c')
-rw-r--r-- | src/machine/machine.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/machine/machine.c b/src/machine/machine.c index dd073addec..05fc4f849f 100644 --- a/src/machine/machine.c +++ b/src/machine/machine.c @@ -80,17 +80,14 @@ void machine_free(Machine *m) { if (m->in_gc_queue) LIST_REMOVE(gc_queue, m->manager->machine_gc_queue, m); - if (m->unit) { - hashmap_remove(m->manager->machine_units, m->unit); - free(m->unit); - } + machine_release_unit(m); free(m->scope_job); - hashmap_remove(m->manager->machines, m->name); + (void) hashmap_remove(m->manager->machines, m->name); if (m->leader > 0) - hashmap_remove_value(m->manager->machine_leaders, UINT_TO_PTR(m->leader), m); + (void) hashmap_remove_value(m->manager->machine_leaders, UINT_TO_PTR(m->leader), m); sd_bus_message_unref(m->create_message); @@ -526,6 +523,17 @@ MachineOperation *machine_operation_unref(MachineOperation *o) { return NULL; } +void machine_release_unit(Machine *m) { + assert(m); + + if (!m->unit) + return; + + (void) hashmap_remove(m->manager->machine_units, m->unit); + free(m->unit); + m->unit = NULL; +} + static const char* const machine_class_table[_MACHINE_CLASS_MAX] = { [MACHINE_CONTAINER] = "container", [MACHINE_VM] = "vm" |