summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/machine/machined.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/src/machine/machined.c b/src/machine/machined.c
index 6550075b56..6eeb053168 100644
--- a/src/machine/machined.c
+++ b/src/machine/machined.c
@@ -275,26 +275,23 @@ int manager_startup(Manager *m) {
return 0;
}
-int manager_run(Manager *m) {
- int r;
-
- assert(m);
+static bool check_idle(void *userdata) {
+ Manager *m = userdata;
- for (;;) {
- r = sd_event_get_state(m->event);
- if (r < 0)
- return r;
- if (r == SD_EVENT_FINISHED)
- return 0;
+ manager_gc(m, true);
- manager_gc(m, true);
+ return hashmap_isempty(m->machines);
+}
- r = sd_event_run(m->event, (uint64_t) -1);
- if (r < 0)
- return r;
- }
+int manager_run(Manager *m) {
+ assert(m);
- return 0;
+ return bus_event_loop_with_idle(
+ m->event,
+ m->bus,
+ "org.freedesktop.machine1",
+ DEFAULT_EXIT_USEC,
+ check_idle, m);
}
int main(int argc, char *argv[]) {