[systemd-devel] [PATCH 5/7] logind: just call session_get_state() to get the session state

Lennart Poettering lennart at poettering.net
Fri Feb 7 07:50:21 PST 2014


On Thu, 06.02.14 21:37, Djalal Harouni (tixxdz at opendz.org) wrote:

This one looks good, but could you rebase it please?

Thanks!

> 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.
> 
> Another point is that session_get_state() will check if the fifo_fd was
> created before checking if the session is active, this is the correct
> behaviour since the session fifo_fd should be considered the point of
> session states synchronization.
> 
> So be consistent and follow the session_get_state() logic.
> ---
>  src/login/logind-user.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/src/login/logind-user.c b/src/login/logind-user.c
> index 8183721..9ed216d 100644
> --- a/src/login/logind-user.c
> +++ b/src/login/logind-user.c
> @@ -637,6 +637,7 @@ void user_add_to_gc_queue(User *u) {
>  
>  UserState user_get_state(User *u) {
>          Session *i;
> +        SessionState session_state;
>          bool all_closing = true;
>  
>          assert(u);
> @@ -645,9 +646,12 @@ UserState user_get_state(User *u) {
>                  return USER_OPENING;
>  
>          LIST_FOREACH(sessions_by_user, i, u->sessions) {
> -                if (session_is_active(i))
> +                /* session_get_state() will check for fifo_fd */
> +                session_state = session_get_state(i);
> +
> +                if (session_state == SESSION_ACTIVE)
>                          return USER_ACTIVE;
> -                if (session_get_state(i) != SESSION_CLOSING)
> +                else if (session_state != SESSION_CLOSING)
>                          all_closing = false;
>          }
>  


Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list