[systemd-devel] [PATCH] logind: use session_get_state() to get sessions state of the user

Lennart Poettering lennart at poettering.net
Tue Feb 11 11:33:13 PST 2014


On Sat, 08.02.14 20:51, Djalal Harouni (tixxdz at opendz.org) wrote:

> In function user_get_state() remove the session_is_active() check, just
> count on the session_get_state() function to get the correct session
> state.
> 
> session_is_active() may return true before starting the session scope
> and user service, this means it will return true even before the creation
> of the session fifo_fd which will produce incorrect states.
> 
> So be consistent and just use session_get_state().

Looks good!

Applied!

Thanks!

> ---
>  src/login/logind-user.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/src/login/logind-user.c b/src/login/logind-user.c
> index fdbf6e3..2a11bab 100644
> --- a/src/login/logind-user.c
> +++ b/src/login/logind-user.c
> @@ -648,9 +648,11 @@ UserState user_get_state(User *u) {
>                  bool all_closing = true;
>  
>                  LIST_FOREACH(sessions_by_user, i, u->sessions) {
> -                        if (session_is_active(i))
> +                        SessionState state = session_get_state(i);
> +
> +                        if (state == SESSION_ACTIVE)
>                                  return USER_ACTIVE;
> -                        if (session_get_state(i) != SESSION_CLOSING)
> +                        else if (state != SESSION_CLOSING)
>                                  all_closing = false;
>                  }
>  


Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list