77 lines
2.7 KiB
Diff
77 lines
2.7 KiB
Diff
|
|
From dcb86edde5ef3b70f68abb7ed8bb0be63f28485b Mon Sep 17 00:00:00 2001
|
||
|
|
From: Florian Schmaus <flo@geekplace.eu>
|
||
|
|
Date: Sat, 16 Nov 2024 10:29:35 +0100
|
||
|
|
Subject: [PATCH] logind: let system-wide idle begin at the time logind was
|
||
|
|
initialized
|
||
|
|
|
||
|
|
Initialize the start of the system-wide idle time with the time logind was
|
||
|
|
initialized and not with the start of the Unix epoch. This means that systemd
|
||
|
|
will not repport a unreasonable long idle time (around 54 years at the time of
|
||
|
|
writing this), especially at in the early boot, while no login manager session,
|
||
|
|
e.g,. gdm, had a chance to provide a more accurate start of the idle period.
|
||
|
|
|
||
|
|
Fixes #35163
|
||
|
|
|
||
|
|
(cherry picked from commit 718b31138b9a93f262259f297ad6b521454decc6)
|
||
|
|
(cherry picked from commit 9d36809256c6d92c6d8358769479ad2c2b695664)
|
||
|
|
(cherry picked from commit 77b963c31712ef81786fcc6623fe1b10a46b62e0)
|
||
|
|
(cherry picked from commit cd6f07effafdcb9e1c903589a8cf398cd46b8acd)
|
||
|
|
|
||
|
|
Conflict:NA
|
||
|
|
Reference:https://github.com/systemd/systemd-stable/commit/dcb86edde5ef3b70f68abb7ed8bb0be63f28485b
|
||
|
|
---
|
||
|
|
src/login/logind-core.c | 6 +++++-
|
||
|
|
src/login/logind.c | 2 ++
|
||
|
|
src/login/logind.h | 2 ++
|
||
|
|
3 files changed, 9 insertions(+), 1 deletion(-)
|
||
|
|
|
||
|
|
diff --git a/src/login/logind-core.c b/src/login/logind-core.c
|
||
|
|
index c47f7f0d8b..ac91a68682 100644
|
||
|
|
--- a/src/login/logind-core.c
|
||
|
|
+++ b/src/login/logind-core.c
|
||
|
|
@@ -399,10 +399,14 @@ int manager_get_user_by_pid(Manager *m, pid_t pid, User **ret) {
|
||
|
|
int manager_get_idle_hint(Manager *m, dual_timestamp *t) {
|
||
|
|
Session *s;
|
||
|
|
bool idle_hint;
|
||
|
|
- dual_timestamp ts = DUAL_TIMESTAMP_NULL;
|
||
|
|
+ dual_timestamp ts;
|
||
|
|
|
||
|
|
assert(m);
|
||
|
|
|
||
|
|
+ /* Initialize the baseline timestamp with the time the manager got initialized to avoid reporting
|
||
|
|
+ * unreasonable large idle periods starting with the Unix epoch. */
|
||
|
|
+ ts = m->init_ts;
|
||
|
|
+
|
||
|
|
idle_hint = !manager_is_inhibited(m, INHIBIT_IDLE, INHIBIT_BLOCK, t, false, false, 0, NULL);
|
||
|
|
|
||
|
|
HASHMAP_FOREACH(s, m->sessions) {
|
||
|
|
diff --git a/src/login/logind.c b/src/login/logind.c
|
||
|
|
index 88e05bb769..23c906f144 100644
|
||
|
|
--- a/src/login/logind.c
|
||
|
|
+++ b/src/login/logind.c
|
||
|
|
@@ -102,6 +102,8 @@ static int manager_new(Manager **ret) {
|
||
|
|
|
||
|
|
(void) sd_event_set_watchdog(m->event, true);
|
||
|
|
|
||
|
|
+ dual_timestamp_now(&m->init_ts);
|
||
|
|
+
|
||
|
|
manager_reset_config(m);
|
||
|
|
|
||
|
|
*ret = TAKE_PTR(m);
|
||
|
|
diff --git a/src/login/logind.h b/src/login/logind.h
|
||
|
|
index 7532d379c0..51a510ed78 100644
|
||
|
|
--- a/src/login/logind.h
|
||
|
|
+++ b/src/login/logind.h
|
||
|
|
@@ -139,6 +139,8 @@ struct Manager {
|
||
|
|
|
||
|
|
char *efi_loader_entry_one_shot;
|
||
|
|
struct stat efi_loader_entry_one_shot_stat;
|
||
|
|
+
|
||
|
|
+ dual_timestamp init_ts;
|
||
|
|
};
|
||
|
|
|
||
|
|
void manager_reset_config(Manager *m);
|
||
|
|
--
|
||
|
|
2.33.0
|
||
|
|
|