X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=src%2Fmachine%2Fmachined.c;h=c8ad157326549f3004cc197f88552d6104ac1277;hb=3e044c492e3ebe64f4e3175c94f9db8a62557b82;hp=9bfe2add54718905eb4bd0b25e74b4c8d4be5f93;hpb=72c0a2c255b172ebbb2a2b7dab7c9aec4c9582d9;p=thirdparty%2Fsystemd.git diff --git a/src/machine/machined.c b/src/machine/machined.c index 9bfe2add547..c8ad1573265 100644 --- a/src/machine/machined.c +++ b/src/machine/machined.c @@ -247,8 +247,16 @@ 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)) { + /* First, if we are not closing yet, initiate stopping */ + if (!machine_check_gc(machine, drop_not_started) && + machine_get_state(machine) != MACHINE_CLOSING) machine_stop(machine); + + /* Now, the stop stop probably made this referenced + * again, but if it didn't, then it's time to let it + * go entirely. */ + if (!machine_check_gc(machine, drop_not_started)) { + machine_finalize(machine); machine_free(machine); } } @@ -347,8 +355,7 @@ int main(int argc, char *argv[]) { log_debug("systemd-machined stopped as pid "PID_FMT, getpid()); finish: - if (m) - manager_free(m); + manager_free(m); return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; }