X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Flogin%2Flogind-user.c;h=fdbf6e3aa08ef73df5e30a283932004e49e34b45;hp=bfbdfaf54798eee3ce926500748b06581bb69aea;hb=ecd2f2c5947d9e2f4d6792c2a3a90b8ced6a5b3e;hpb=cc3773810855956bad92337cee8fa193584ab62e diff --git a/src/login/logind-user.c b/src/login/logind-user.c index bfbdfaf54..fdbf6e3aa 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; @@ -587,7 +589,7 @@ int user_get_idle_hint(User *u, dual_timestamp *t) { return idle_hint; } -static int user_check_linger_file(User *u) { +int user_check_linger_file(User *u) { _cleanup_free_ char *cc = NULL; char *p = NULL; @@ -618,12 +620,6 @@ bool user_check_gc(User *u, bool drop_not_started) { if (u->service_job && manager_job_is_active(u->manager, u->service_job)) return true; - if (u->slice && manager_unit_is_active(u->manager, u->slice) != 0) - return true; - - if (u->service && manager_unit_is_active(u->manager, u->service) != 0) - return true; - return false; } @@ -639,25 +635,27 @@ 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) { + if (session_is_active(i)) + return USER_ACTIVE; + if (session_get_state(i) != 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;