X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flogin%2Flogind-user.c;h=4af0e90c2232d36d9c790085151d5765166eb09f;hb=d9d93745cd2efcdfca8f82d798e61e0ee70cef5c;hp=bdb69156300d684947cc163630a19780516162eb;hpb=90b2de37b80603168f4e9c9c81cff7eea4efa21a;p=elogind.git diff --git a/src/login/logind-user.c b/src/login/logind-user.c index bdb691563..4af0e90c2 100644 --- a/src/login/logind-user.c +++ b/src/login/logind-user.c @@ -494,13 +494,19 @@ static int user_remove_runtime_path(User *u) { return r; } -int user_stop(User *u) { +int user_stop(User *u, bool force) { Session *s; int r = 0, k; assert(u); + /* Stop jobs have already been queued */ + if (u->stopping) { + user_save(u); + return r; + } + LIST_FOREACH(sessions_by_user, s, u->sessions) { - k = session_stop(s); + k = session_stop(s, force); if (k < 0) r = k; } @@ -515,6 +521,8 @@ int user_stop(User *u) { if (k < 0) r = k; + u->stopping = true; + user_save(u); return r; @@ -633,22 +641,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->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;