diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-12-19 21:15:08 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-12-19 22:18:39 +0100 |
commit | d9e34bfda3d34dcde00a876cb052e7de0655e1cb (patch) | |
tree | ead467e33f9269b000a07798b92f4352685a1eaf /src/machine | |
parent | 37224a5ff522a366b353e8a01e2c2eee1e5416e5 (diff) |
machined: implement exit-on-idle
Diffstat (limited to 'src/machine')
-rw-r--r-- | src/machine/machined.c | 29 |
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[]) { |