mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-24 21:34:08 +03:00
logind: fix delayed execution regression
Commit c0f32805
("logind: use sd_event timer source for inhibitor
logic") reworked the main loop logic of logind so that it uses a
real timeout callback handler to execute delayed functions.
What the old code did, however, was to call those functions on
every iteration in the main loop, not only when the timeout
expired.
Restore that behavior by bringing back manager_dispatch_delayed(),
and call it from manager_run(). The internal event source callback
manager_inhibit_timeout_handler() was turned into a wrapper of
manager_dispatch_delayed() now.
This commit is contained in:
parent
906fa49076
commit
418b22b88f
@ -1486,18 +1486,13 @@ static int execute_shutdown_or_sleep(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int manager_inhibit_timeout_handler(
|
int manager_dispatch_delayed(Manager *manager, bool timeout) {
|
||||||
sd_event_source *s,
|
|
||||||
uint64_t usec,
|
|
||||||
void *userdata) {
|
|
||||||
|
|
||||||
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
|
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||||
Inhibitor *offending = NULL;
|
Inhibitor *offending = NULL;
|
||||||
Manager *manager = userdata;
|
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(manager);
|
assert(manager);
|
||||||
assert(manager->inhibit_timeout_source == s);
|
|
||||||
|
|
||||||
if (manager->action_what == 0 || manager->action_job)
|
if (manager->action_what == 0 || manager->action_job)
|
||||||
return 0;
|
return 0;
|
||||||
@ -1505,6 +1500,9 @@ static int manager_inhibit_timeout_handler(
|
|||||||
if (manager_is_inhibited(manager, manager->action_what, INHIBIT_DELAY, NULL, false, false, 0, &offending)) {
|
if (manager_is_inhibited(manager, manager->action_what, INHIBIT_DELAY, NULL, false, false, 0, &offending)) {
|
||||||
_cleanup_free_ char *comm = NULL, *u = NULL;
|
_cleanup_free_ char *comm = NULL, *u = NULL;
|
||||||
|
|
||||||
|
if (!timeout)
|
||||||
|
return 0;
|
||||||
|
|
||||||
(void) get_process_comm(offending->pid, &comm);
|
(void) get_process_comm(offending->pid, &comm);
|
||||||
u = uid_to_name(offending->uid);
|
u = uid_to_name(offending->uid);
|
||||||
|
|
||||||
@ -1520,9 +1518,25 @@ static int manager_inhibit_timeout_handler(
|
|||||||
|
|
||||||
manager->action_unit = NULL;
|
manager->action_unit = NULL;
|
||||||
manager->action_what = 0;
|
manager->action_what = 0;
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int manager_inhibit_timeout_handler(
|
||||||
|
sd_event_source *s,
|
||||||
|
uint64_t usec,
|
||||||
|
void *userdata) {
|
||||||
|
|
||||||
|
Manager *manager = userdata;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
assert(manager);
|
||||||
|
assert(manager->inhibit_timeout_source == s);
|
||||||
|
|
||||||
|
r = manager_dispatch_delayed(manager, true);
|
||||||
|
return (r < 0) ? r : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int delay_shutdown_or_sleep(
|
static int delay_shutdown_or_sleep(
|
||||||
|
@ -1109,6 +1109,12 @@ static int manager_run(Manager *m) {
|
|||||||
|
|
||||||
manager_gc(m, true);
|
manager_gc(m, true);
|
||||||
|
|
||||||
|
r = manager_dispatch_delayed(m, false);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
if (r > 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
r = sd_event_run(m->event, (uint64_t) -1);
|
r = sd_event_run(m->event, (uint64_t) -1);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
@ -194,3 +194,5 @@ int manager_get_seat_from_creds(Manager *m, sd_bus_message *message, const char
|
|||||||
|
|
||||||
int manager_setup_wall_message_timer(Manager *m);
|
int manager_setup_wall_message_timer(Manager *m);
|
||||||
bool logind_wall_tty_filter(const char *tty, void *userdata);
|
bool logind_wall_tty_filter(const char *tty, void *userdata);
|
||||||
|
|
||||||
|
int manager_dispatch_delayed(Manager *manager, bool timeout);
|
||||||
|
Loading…
Reference in New Issue
Block a user