summaryrefslogtreecommitdiff
path: root/src/machine/machined-dbus.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-08-06 16:50:54 +0300
committerLennart Poettering <lennart@poettering.net>2015-08-06 16:54:00 +0300
commit49f3fffd94591bdf2bd6c2233a9300daeab79566 (patch)
treee5e43f4adaa79a86e6cd808241a32f53746cf1be /src/machine/machined-dbus.c
parente5a840c93ac8a175a61fc5944d260127ff2247cc (diff)
machined: rework state tracking logic for machines
This splits up the stopping logic for machines into two steps: first on machine_stop() we begin with the shutdown of a machine by queuing the stop method call for it. Then, in machine_finalize() we actually remove the rest of its runtime context. This mimics closely how sessions are handled in logind. This also reworks the GC logic to strictly check the current state of the machine unit, rather than shortcutting a few cases, like for example assuming that UnitRemoved really means a machine is gone (which it isn't since Reloading might trigger it, see #376). Fixes #376.
Diffstat (limited to 'src/machine/machined-dbus.c')
-rw-r--r--src/machine/machined-dbus.c39
1 files changed, 4 insertions, 35 deletions
diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c
index 49f41c62d7..08a7f58ef5 100644
--- a/src/machine/machined-dbus.c
+++ b/src/machine/machined-dbus.c
@@ -1136,8 +1136,9 @@ int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *err
machine_send_create_reply(machine, &e);
}
- } else
- machine_save(machine);
+ }
+
+ machine_save(machine);
}
machine_add_to_gc_queue(machine);
@@ -1146,7 +1147,7 @@ int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *err
int match_properties_changed(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *unit = NULL;
- const char *path, *interface;
+ const char *path;
Manager *m = userdata;
Machine *machine;
int r;
@@ -1170,36 +1171,6 @@ int match_properties_changed(sd_bus_message *message, void *userdata, sd_bus_err
if (!machine)
return 0;
- r = sd_bus_message_read(message, "s", &interface);
- if (r < 0) {
- bus_log_parse_error(r);
- return 0;
- }
-
- if (streq(interface, "org.freedesktop.systemd1.Unit")) {
- struct properties {
- char *active_state;
- char *sub_state;
- } properties = {};
-
- const struct bus_properties_map map[] = {
- { "ActiveState", "s", NULL, offsetof(struct properties, active_state) },
- { "SubState", "s", NULL, offsetof(struct properties, sub_state) },
- {}
- };
-
- r = bus_message_map_properties_changed(message, map, &properties);
- if (r < 0)
- bus_log_parse_error(r);
- else if (streq_ptr(properties.active_state, "inactive") ||
- streq_ptr(properties.active_state, "failed") ||
- streq_ptr(properties.sub_state, "auto-restart"))
- machine_release_unit(machine);
-
- free(properties.active_state);
- free(properties.sub_state);
- }
-
machine_add_to_gc_queue(machine);
return 0;
}
@@ -1223,9 +1194,7 @@ int match_unit_removed(sd_bus_message *message, void *userdata, sd_bus_error *er
if (!machine)
return 0;
- machine_release_unit(machine);
machine_add_to_gc_queue(machine);
-
return 0;
}