summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/machine/machine-dbus.c6
-rw-r--r--src/machine/machine.c2
-rw-r--r--src/machine/machine.h2
-rw-r--r--src/machine/machined-dbus.c31
-rw-r--r--src/machine/machined.c8
-rw-r--r--src/machine/machined.h1
6 files changed, 23 insertions, 27 deletions
diff --git a/src/machine/machine-dbus.c b/src/machine/machine-dbus.c
index 150a3f7761..ddd6b4b10e 100644
--- a/src/machine/machine-dbus.c
+++ b/src/machine/machine-dbus.c
@@ -210,13 +210,13 @@ int machine_send_create_reply(Machine *m, sd_bus_error *error) {
c = m->create_message;
m->create_message = NULL;
+ if (error)
+ return sd_bus_reply_method_error(m->manager->bus, c, error);
+
/* Update the machine state file before we notify the client
* about the result. */
machine_save(m);
- if (error)
- return sd_bus_reply_method_error(m->manager->bus, c, error);
-
p = machine_bus_path(m);
if (!p)
return -ENOMEM;
diff --git a/src/machine/machine.c b/src/machine/machine.c
index be669f02dc..a33a111043 100644
--- a/src/machine/machine.c
+++ b/src/machine/machine.c
@@ -338,7 +338,7 @@ int machine_stop(Machine *m) {
return r;
}
-int machine_check_gc(Machine *m, bool drop_not_started) {
+bool machine_check_gc(Machine *m, bool drop_not_started) {
assert(m);
if (drop_not_started && !m->started)
diff --git a/src/machine/machine.h b/src/machine/machine.h
index bfb28d1e8e..99ee25888e 100644
--- a/src/machine/machine.h
+++ b/src/machine/machine.h
@@ -80,7 +80,7 @@ struct Machine {
Machine* machine_new(Manager *manager, const char *name);
void machine_free(Machine *m);
-int machine_check_gc(Machine *m, bool drop_not_started);
+bool machine_check_gc(Machine *m, bool drop_not_started);
void machine_add_to_gc_queue(Machine *m);
int machine_start(Machine *m, sd_bus_message *properties, sd_bus_error *error);
int machine_stop(Machine *m);
diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c
index 6035597913..b55266249b 100644
--- a/src/machine/machined-dbus.c
+++ b/src/machine/machined-dbus.c
@@ -335,9 +335,9 @@ const sd_bus_vtable manager_vtable[] = {
};
int machine_node_enumerator(sd_bus *bus, const char *path, char ***nodes, void *userdata) {
+ _cleanup_strv_free_ char **l = NULL;
Machine *machine = NULL;
Manager *m = userdata;
- char **l = NULL;
Iterator i;
int r;
@@ -360,6 +360,8 @@ int machine_node_enumerator(sd_bus *bus, const char *path, char ***nodes, void *
}
*nodes = l;
+ l = NULL;
+
return 1;
}
@@ -456,6 +458,8 @@ int match_unit_removed(sd_bus *bus, sd_bus_message *message, void *userdata) {
int match_reloading(sd_bus *bus, sd_bus_message *message, void *userdata) {
Manager *m = userdata;
+ Machine *machine;
+ Iterator i;
int b, r;
assert(bus);
@@ -466,16 +470,14 @@ int match_reloading(sd_bus *bus, sd_bus_message *message, void *userdata) {
return 0;
}
- /* systemd finished reloading, let's recheck all our machines */
- if (!b) {
- Machine *machine;
- Iterator i;
+ if (b)
+ return 0;
- log_debug("System manager has been reloaded, rechecking machines...");
+ /* systemd finished reloading, let's recheck all our machines */
+ log_debug("System manager has been reloaded, rechecking machines...");
- HASHMAP_FOREACH(machine, m->machines, i)
- machine_add_to_gc_queue(machine);
- }
+ HASHMAP_FOREACH(machine, m->machines, i)
+ machine_add_to_gc_queue(machine);
return 0;
}
@@ -507,7 +509,7 @@ int manager_start_scope(
if (r < 0)
return r;
- r = sd_bus_message_append(m, "ss", scope, "fail");
+ r = sd_bus_message_append(m, "ss", strempty(scope), "fail");
if (r < 0)
return r;
@@ -620,23 +622,18 @@ int manager_stop_unit(Manager *manager, const char *unit, sd_bus_error *error, c
}
int manager_kill_unit(Manager *manager, const char *unit, KillWho who, int signo, sd_bus_error *error) {
- _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
- int r;
-
assert(manager);
assert(unit);
- r = sd_bus_call_method(
+ return sd_bus_call_method(
manager->bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"KillUnit",
error,
- &reply,
+ NULL,
"ssi", unit, who == KILL_LEADER ? "main" : "all", signo);
-
- return r;
}
int manager_unit_is_active(Manager *manager, const char *unit) {
diff --git a/src/machine/machined.c b/src/machine/machined.c
index 63915519c1..25de0d5d46 100644
--- a/src/machine/machined.c
+++ b/src/machine/machined.c
@@ -47,13 +47,13 @@ Manager *manager_new(void) {
m->machines = hashmap_new(string_hash_func, string_compare_func);
m->machine_units = hashmap_new(string_hash_func, string_compare_func);
- r = sd_event_new(&m->event);
- if (r < 0) {
+ if (!m->machines || !m->machine_units) {
manager_free(m);
return NULL;
}
- if (!m->machines || !m->machine_units) {
+ r = sd_event_new(&m->event);
+ if (r < 0) {
manager_free(m);
return NULL;
}
@@ -284,7 +284,7 @@ void manager_gc(Manager *m, bool drop_not_started) {
LIST_REMOVE(gc_queue, m->machine_gc_queue, machine);
machine->in_gc_queue = false;
- if (machine_check_gc(machine, drop_not_started) == 0) {
+ if (!machine_check_gc(machine, drop_not_started)) {
machine_stop(machine);
machine_free(machine);
}
diff --git a/src/machine/machined.h b/src/machine/machined.h
index c47a468830..dfb63bd7f1 100644
--- a/src/machine/machined.h
+++ b/src/machine/machined.h
@@ -48,7 +48,6 @@ Manager *manager_new(void);
void manager_free(Manager *m);
int manager_add_machine(Manager *m, const char *name, Machine **_machine);
-
int manager_enumerate_machines(Manager *m);
int manager_startup(Manager *m);