X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flogin%2Flogind-user.c;h=a6672ce670acd7180bec825de3c3766cc9c1d8a3;hb=47acb2f15f2319ec0fc341a4271d45067da2ed24;hp=fca68159a7c556e43f48c96fde23aeb1beae235c;hpb=669241a076108e0483d7d8475beaa506106d077e;p=elogind.git diff --git a/src/login/logind-user.c b/src/login/logind-user.c index fca68159a..a6672ce67 100644 --- a/src/login/logind-user.c +++ b/src/login/logind-user.c @@ -189,7 +189,9 @@ int user_save(User *u) { if (first) first = false; else - fputs(i->seat->id, f); + fputc(' ', f); + + fputs(i->seat->id, f); } fputc('\n', f); } @@ -259,10 +261,8 @@ static int user_mkdir_runtime_path(User *u) { } if (!u->runtime_path) { - if (asprintf(&p, "/run/user/%lu", (unsigned long) u->uid) < 0) { - log_error("Out of memory."); - return -ENOMEM; - } + if (asprintf(&p, "/run/user/%lu", (unsigned long) u->uid) < 0) + return log_oom(); } else p = u->runtime_path; @@ -286,10 +286,8 @@ static int user_create_cgroup(User *u) { assert(u); if (!u->cgroup_path) { - if (asprintf(&p, "%s/%s", u->manager->cgroup_path, u->name) < 0) { - log_error("Out of memory."); - return -ENOMEM; - } + if (asprintf(&p, "%s/%s", u->manager->cgroup_path, u->name) < 0) + return log_oom(); } else p = u->cgroup_path; @@ -572,15 +570,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;