logind: preserve scheduled shutdown on failure
Do not discard an existing scheduled shutdown until the new action
has been accepted. Keep failed D-Bus and Varlink requests from
cancelling the pending shutdown.
Follow-up for: 5ed73478e1
This commit is contained in:
committed by
Yu Watanabe
parent
768b6f21ec
commit
83e9162b93
@@ -2327,7 +2327,11 @@ static int method_do_shutdown_or_sleep(
|
||||
handle_action_to_string(m->delayed_action->handle),
|
||||
handle_action_to_string(a->handle));
|
||||
|
||||
/* reset case we're shorting a scheduled shutdown */
|
||||
r = bus_manager_shutdown_or_sleep_now_or_later(m, a, error);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
/* Reset in case we're short-circuiting a scheduled shutdown. */
|
||||
m->unlink_nologin = false;
|
||||
manager_reset_scheduled_shutdown(m);
|
||||
|
||||
@@ -2336,10 +2340,6 @@ static int method_do_shutdown_or_sleep(
|
||||
|
||||
(void) setup_wall_message_timer(m, message);
|
||||
|
||||
r = bus_manager_shutdown_or_sleep_now_or_later(m, a, error);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return sd_bus_reply_method_return(message, NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -820,15 +820,6 @@ static int manager_do_shutdown_action(sd_varlink *link, sd_json_variant *paramet
|
||||
if (m->delayed_action)
|
||||
return sd_varlink_error(link, "io.systemd.Shutdown.AlreadyInProgress", /* parameters= */ NULL);
|
||||
|
||||
/* Reset in case we're short-circuiting a scheduled shutdown */
|
||||
m->unlink_nologin = false;
|
||||
manager_reset_scheduled_shutdown(m);
|
||||
|
||||
m->scheduled_shutdown_timeout = 0;
|
||||
m->scheduled_shutdown_action = action;
|
||||
|
||||
(void) setup_wall_message_timer(m, link);
|
||||
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
r = bus_manager_shutdown_or_sleep_now_or_later(m, a, &error);
|
||||
if (r < 0) {
|
||||
@@ -838,6 +829,15 @@ static int manager_do_shutdown_action(sd_varlink *link, sd_json_variant *paramet
|
||||
return sd_varlink_error_errno(link, r);
|
||||
}
|
||||
|
||||
/* Reset in case we're short-circuiting a scheduled shutdown. */
|
||||
m->unlink_nologin = false;
|
||||
manager_reset_scheduled_shutdown(m);
|
||||
|
||||
m->scheduled_shutdown_timeout = 0;
|
||||
m->scheduled_shutdown_action = action;
|
||||
|
||||
(void) setup_wall_message_timer(m, link);
|
||||
|
||||
return sd_varlink_reply(link, NULL);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user