X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flogin%2Flogind-user.c;h=06fdbb36fc9758fc307b1dc43000db5fc8609181;hb=00555a2ee1b008bccbb570320047307b8b9159f9;hp=441e0860d9500f1e658ed5f566c6bc93863194e6;hpb=63966da86d8e71b1f3f2b57d5448770d526421f9;p=elogind.git diff --git a/src/login/logind-user.c b/src/login/logind-user.c index 441e0860d..06fdbb36f 100644 --- a/src/login/logind-user.c +++ b/src/login/logind-user.c @@ -145,10 +145,10 @@ int user_save(User *u) { if (dual_timestamp_is_set(&u->timestamp)) fprintf(f, - "REALTIME=%llu\n" - "MONOTONIC=%llu\n", - (unsigned long long) u->timestamp.realtime, - (unsigned long long) u->timestamp.monotonic); + "REALTIME="USEC_FMT"\n" + "MONOTONIC="USEC_FMT"\n", + u->timestamp.realtime, + u->timestamp.monotonic); if (u->sessions) { Session *i; @@ -247,7 +247,7 @@ int user_save(User *u) { finish: if (r < 0) - log_error("Failed to save user data for %s: %s", u->name, strerror(-r)); + log_error("Failed to save user data %s: %s", u->state_file, strerror(-r)); return r; } @@ -515,6 +515,8 @@ int user_stop(User *u) { if (k < 0) r = k; + u->stopping = true; + user_save(u); return r; @@ -633,25 +635,30 @@ void user_add_to_gc_queue(User *u) { UserState user_get_state(User *u) { Session *i; - bool all_closing = true; assert(u); - if (u->closing) + if (u->stopping) return USER_CLOSING; if (u->slice_job || u->service_job) return USER_OPENING; - 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) { + bool all_closing = true; + + LIST_FOREACH(sessions_by_user, i, u->sessions) { + SessionState state; + + state = session_get_state(i); + if (state == SESSION_ACTIVE) + return USER_ACTIVE; + if (state != SESSION_CLOSING) + all_closing = false; + } - if (u->sessions) return all_closing ? USER_CLOSING : USER_ONLINE; + } if (user_check_linger_file(u) > 0) return USER_LINGERING;