]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind: don't make idle action timer accuracy more coarse than timeout
authorLennart Poettering <lennart@poettering.net>
Wed, 29 Nov 2023 10:07:08 +0000 (11:07 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 4 Jan 2024 14:29:09 +0000 (23:29 +0900)
If we allow the timer accuracy to grow larger then the timeout itself
things are very confusing, because people might set a 1s time-out and we
turn that into 30s.

Hence, let's just cut off the 30s accuracy to the time-out itself, so
that we stay close to what users configured.

src/login/logind.c

index 4123e6bb1922165f9af2602bef37d66af539536b..030f65da088a32411daa2962dd0bf62dfc738ddb 100644 (file)
@@ -1036,7 +1036,7 @@ static int manager_dispatch_idle_action(sd_event_source *s, uint64_t t, void *us
                                 m->event,
                                 &m->idle_action_event_source,
                                 CLOCK_MONOTONIC,
-                                elapse, USEC_PER_SEC*30,
+                                elapse, MIN(USEC_PER_SEC*30, m->idle_action_usec), /* accuracy of 30s, but don't have an accuracy lower than the idle action timeout */
                                 manager_dispatch_idle_action, m);
                 if (r < 0)
                         return log_error_errno(r, "Failed to add idle event source: %m");