From: Colin Guthrie Date: Mon, 3 Sep 2012 22:47:01 +0000 (+0100) Subject: logind: If all user sessions are in closing state, set the overall status to closing. X-Git-Tag: v190~130 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=c9caad802128a5dc599342c1400a61f31e8b17b5;hp=f904bdf2e9f6f858802489ab07ff070d4677bccb;p=elogind.git logind: If all user sessions are in closing state, set the overall status to closing. PulseAudio for example will keep a client connection open provided at least one session exists. However, if all sessions are currently in the process of closing, we should flag that as the overall state appropriately to better reflect what is happening. Although this does better reflect the status for any given user, it does not actually solve the overall problem of PulseAudio still finding some sessions active and thus not exiting and therefore actually preventing the session from closing. Future commits will extend sd-login to cope with this situation. --- diff --git a/src/login/logind-user.c b/src/login/logind-user.c index aa9c3f1a3..a33978c18 100644 --- a/src/login/logind-user.c +++ b/src/login/logind-user.c @@ -568,15 +568,20 @@ void user_add_to_gc_queue(User *u) { UserState user_get_state(User *u) { Session *i; + bool all_closing = true; assert(u); - LIST_FOREACH(sessions_by_user, i, u->sessions) + + LIST_FOREACH(sessions_by_user, i, u->sessions) { if (session_is_active(i)) return USER_ACTIVE; + if (session_get_state(i) != SESSION_CLOSING) + all_closing = false; + } if (u->sessions) - return USER_ONLINE; + return all_closing ? USER_CLOSING : USER_ONLINE; if (user_check_linger_file(u) > 0) return USER_LINGERING;