summaryrefslogtreecommitdiff
path: root/src/login/logind-user.c
diff options
context:
space:
mode:
authorColin Guthrie <colin@mageia.org>2012-09-03 23:57:58 +0100
committerLennart Poettering <lennart@poettering.net>2012-09-12 08:19:54 +0200
commit2dc8f41a2bdcc25e6ec69a99cb6f34615cce59a5 (patch)
tree12c1cc3e2f87ea60926beb00b476f73a0fbbd195 /src/login/logind-user.c
parent47acb2f15f2319ec0fc341a4271d45067da2ed24 (diff)
logind: Add a two new variables to the user session tracking file.
This counts 'online sessions' in addition to 'active sessions' and 'sessions'. In this context, an 'online session' covers all session in the 'active' state in addition to the explicit 'online' state. This provides an easy machanism to determin all relevant sessions easily (i.e. those that are not 'closing') and adds new semantics to the sd-login.c APIs sd_uid_get_sessions() and sd_uid_get_seats() where the require_active argument can be supplied as a value 2 which only lists sessions which are 'online'. This functionality should allow client applications to avoid deadlocks where they only exit when all sessions are complete, such as a the problem where PulseAudio will not exit until all sessions are gone, but in itself prevents the session from exiting.
Diffstat (limited to 'src/login/logind-user.c')
-rw-r--r--src/login/logind-user.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/login/logind-user.c b/src/login/logind-user.c
index a6672ce670..9dfead9d5d 100644
--- a/src/login/logind-user.c
+++ b/src/login/logind-user.c
@@ -180,6 +180,20 @@ int user_save(User *u) {
fputs(i->id, f);
}
+ fputs("\nONLINE_SESSIONS=", f);
+ first = true;
+ LIST_FOREACH(sessions_by_user, i, u->sessions) {
+ if (session_get_state(i) == SESSION_CLOSING)
+ continue;
+
+ if (first)
+ first = false;
+ else
+ fputc(' ', f);
+
+ fputs(i->id, f);
+ }
+
fputs("\nACTIVE_SEATS=", f);
first = true;
LIST_FOREACH(sessions_by_user, i, u->sessions) {
@@ -193,6 +207,20 @@ int user_save(User *u) {
fputs(i->seat->id, f);
}
+
+ fputs("\nONLINE_SEATS=", f);
+ first = true;
+ LIST_FOREACH(sessions_by_user, i, u->sessions) {
+ if (session_get_state(i) == SESSION_CLOSING || !i->seat)
+ continue;
+
+ if (first)
+ first = false;
+ else
+ fputc(' ', f);
+
+ fputs(i->seat->id, f);
+ }
fputc('\n', f);
}