diff options
author | Lennart Poettering <lennart@poettering.net> | 2011-06-17 15:59:18 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2011-06-21 19:29:45 +0200 |
commit | a185c5aa2d8bef98716f8cf160da263c17e588b2 (patch) | |
tree | ef6ff057c606efefe86b34503fe92bf40cf05b6d /src/logind-user.c | |
parent | 91f9dcaf9270fe465525638cc08bd94590273349 (diff) |
logind: implement idle hint logic
Diffstat (limited to 'src/logind-user.c')
-rw-r--r-- | src/logind-user.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/src/logind-user.c b/src/logind-user.c index 7d6df8db7a..206064f103 100644 --- a/src/logind-user.c +++ b/src/logind-user.c @@ -156,7 +156,7 @@ int user_load(User *u) { assert(u); - r = parse_env_file(u->state_file, "r", + r = parse_env_file(u->state_file, NEWLINE, "CGROUP", &u->cgroup_path, "RUNTIME", &u->runtime_path, "SERVICE", &u->service, @@ -386,6 +386,42 @@ int user_stop(User *u) { return r; } +int user_get_idle_hint(User *u, dual_timestamp *t) { + Session *s; + bool idle_hint = true; + dual_timestamp ts = { 0, 0 }; + + assert(u); + + LIST_FOREACH(sessions_by_user, s, u->sessions) { + dual_timestamp k; + int ih; + + ih = session_get_idle_hint(s, &k); + if (ih < 0) + return ih; + + if (!ih) { + if (!idle_hint) { + if (k.monotonic < ts.monotonic) + ts = k; + } else { + idle_hint = false; + ts = k; + } + } else if (idle_hint) { + + if (k.monotonic > ts.monotonic) + ts = k; + } + } + + if (t) + *t = ts; + + return idle_hint; +} + int user_check_gc(User *u) { int r; char *p; |