diff options
author | Daniel Mack <github@zonque.org> | 2015-08-06 16:13:22 +0200 |
---|---|---|
committer | Daniel Mack <github@zonque.org> | 2015-08-06 16:13:22 +0200 |
commit | 3996b5251ddfcbe0809d1116821f003f2bca45ef (patch) | |
tree | cd362f9d5068d9c21fa1fa26b9d772f7bf2fdd85 /src/machine/machine.c | |
parent | cedafc8a7203c788cc45ecaa26935428a7553544 (diff) | |
parent | 49f3fffd94591bdf2bd6c2233a9300daeab79566 (diff) |
Merge pull request #898 from poettering/machined-fix-reload
Fix for #376, plus some other fixes
Diffstat (limited to 'src/machine/machine.c')
-rw-r--r-- | src/machine/machine.c | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/src/machine/machine.c b/src/machine/machine.c index ab26803683..f045159d41 100644 --- a/src/machine/machine.c +++ b/src/machine/machine.c @@ -231,11 +231,11 @@ static void machine_unlink(Machine *m) { char *sl; sl = strjoina("/run/systemd/machines/unit:", m->unit); - unlink(sl); + (void) unlink(sl); } if (m->state_file) - unlink(m->state_file); + (void) unlink(m->state_file); } int machine_load(Machine *m) { @@ -419,7 +419,19 @@ static int machine_stop_scope(Machine *m) { } int machine_stop(Machine *m) { - int r = 0, k; + int r; + assert(m); + + r = machine_stop_scope(m); + + m->stopping = true; + + machine_save(m); + + return r; +} + +int machine_finalize(Machine *m) { assert(m); if (m->started) @@ -430,20 +442,15 @@ int machine_stop(Machine *m) { LOG_MESSAGE("Machine %s terminated.", m->name), NULL); - /* Kill cgroup */ - k = machine_stop_scope(m); - if (k < 0) - r = k; - machine_unlink(m); machine_add_to_gc_queue(m); - if (m->started) + if (m->started) { machine_send_signal(m, false); + m->started = false; + } - m->started = false; - - return r; + return 0; } bool machine_check_gc(Machine *m, bool drop_not_started) { @@ -474,8 +481,11 @@ void machine_add_to_gc_queue(Machine *m) { MachineState machine_get_state(Machine *s) { assert(s); + if (s->stopping) + return MACHINE_CLOSING; + if (s->scope_job) - return s->started ? MACHINE_OPENING : MACHINE_CLOSING; + return MACHINE_OPENING; return MACHINE_RUNNING; } |