diff options
author | Lennart Poettering <lennart@poettering.net> | 2012-04-16 17:05:15 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2012-04-16 18:59:08 +0200 |
commit | c7b5eb98e8eeafe63a079ee3c51e9670872437ae (patch) | |
tree | 1c0d5ae1028169f4b3e96f20bbf30a4f9cebcd27 /src/login/logind-inhibit.c | |
parent | f8e2fb7b14e53f5a4bcfd66d26910af1dee185c6 (diff) |
logind: hook up inhibit logic with idle hint logic
Diffstat (limited to 'src/login/logind-inhibit.c')
-rw-r--r-- | src/login/logind-inhibit.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/login/logind-inhibit.c b/src/login/logind-inhibit.c index 2f7a758e7c..78afee3139 100644 --- a/src/login/logind-inhibit.c +++ b/src/login/logind-inhibit.c @@ -150,6 +150,8 @@ int inhibitor_start(Inhibitor *i) { if (i->started) return 0; + dual_timestamp_get(&i->since); + log_debug("Inhibitor %s (%s) pid=%lu uid=%lu started.", strna(i->who), strna(i->why), (unsigned long) i->pid, (unsigned long) i->uid); @@ -325,6 +327,32 @@ InhibitWhat manager_inhibit_what(Manager *m) { return what; } +bool manager_is_inhibited(Manager *m, InhibitWhat w, dual_timestamp *since) { + Inhibitor *i; + Iterator j; + struct dual_timestamp ts = { 0, 0 }; + bool inhibited = false; + + assert(m); + assert(w > 0 && w < _INHIBIT_WHAT_MAX); + + HASHMAP_FOREACH(i, m->inhibitor_fds, j) { + if (!(i->what & w)) + continue; + + if (!inhibited || + i->since.monotonic < ts.monotonic) + ts = i->since; + + inhibited = true; + } + + if (since) + *since = ts; + + return inhibited; +} + const char *inhibit_what_to_string(InhibitWhat w) { static const char* const table[_INHIBIT_WHAT_MAX] = { |