From: Zbigniew Jędrzejewski-Szmek Date: Thu, 15 Feb 2018 12:14:35 +0000 (+0100) Subject: logind: change check_gc to may_gc everywhere X-Git-Tag: v238~97^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5c093a23688ff4d98657da44c25848392a0caf69;p=thirdparty%2Fsystemd.git logind: change check_gc to may_gc everywhere --- diff --git a/src/login/logind-seat.c b/src/login/logind-seat.c index b99e7abf911..46e7c06ddca 100644 --- a/src/login/logind-seat.c +++ b/src/login/logind-seat.c @@ -639,16 +639,16 @@ int seat_get_idle_hint(Seat *s, dual_timestamp *t) { return idle_hint; } -bool seat_check_gc(Seat *s, bool drop_not_started) { +bool seat_may_gc(Seat *s, bool drop_not_started) { assert(s); if (drop_not_started && !s->started) - return false; + return true; if (seat_is_seat0(s)) - return true; + return false; - return seat_has_master_device(s); + return !seat_has_master_device(s); } void seat_add_to_gc_queue(Seat *s) { diff --git a/src/login/logind-seat.h b/src/login/logind-seat.h index 5427ac21c86..4982ea33813 100644 --- a/src/login/logind-seat.h +++ b/src/login/logind-seat.h @@ -79,7 +79,7 @@ int seat_start(Seat *s); int seat_stop(Seat *s, bool force); int seat_stop_sessions(Seat *s, bool force); -bool seat_check_gc(Seat *s, bool drop_not_started); +bool seat_may_gc(Seat *s, bool drop_not_started); void seat_add_to_gc_queue(Seat *s); bool seat_name_is_valid(const char *name); diff --git a/src/login/logind-session.c b/src/login/logind-session.c index 92eb2943fe7..1859150b5e8 100644 --- a/src/login/logind-session.c +++ b/src/login/logind-session.c @@ -1000,27 +1000,27 @@ static void session_remove_fifo(Session *s) { } } -bool session_check_gc(Session *s, bool drop_not_started) { +bool session_may_gc(Session *s, bool drop_not_started) { assert(s); if (drop_not_started && !s->started) - return false; + return true; if (!s->user) - return false; + return true; if (s->fifo_fd >= 0) { if (pipe_eof(s->fifo_fd) <= 0) - return true; + return false; } if (s->scope_job && manager_job_is_active(s->manager, s->scope_job)) - return true; + return false; if (s->scope && manager_unit_is_active(s->manager, s->scope)) - return true; + return false; - return false; + return true; } void session_add_to_gc_queue(Session *s) { diff --git a/src/login/logind-session.h b/src/login/logind-session.h index 8491832402c..16a278c7926 100644 --- a/src/login/logind-session.h +++ b/src/login/logind-session.h @@ -131,7 +131,7 @@ struct Session { Session *session_new(Manager *m, const char *id); void session_free(Session *s); void session_set_user(Session *s, User *u); -bool session_check_gc(Session *s, bool drop_not_started); +bool session_may_gc(Session *s, bool drop_not_started); void session_add_to_gc_queue(Session *s); int session_activate(Session *s); bool session_is_active(Session *s); diff --git a/src/login/logind-user.c b/src/login/logind-user.c index 32b2045696c..f85564f221f 100644 --- a/src/login/logind-user.c +++ b/src/login/logind-user.c @@ -680,25 +680,25 @@ int user_check_linger_file(User *u) { return access(p, F_OK) >= 0; } -bool user_check_gc(User *u, bool drop_not_started) { +bool user_may_gc(User *u, bool drop_not_started) { assert(u); if (drop_not_started && !u->started) - return false; + return true; if (u->sessions) - return true; + return false; if (user_check_linger_file(u) > 0) - return true; + return false; if (u->slice_job && manager_job_is_active(u->manager, u->slice_job)) - return true; + return false; if (u->service_job && manager_job_is_active(u->manager, u->service_job)) - return true; + return false; - return false; + return true; } void user_add_to_gc_queue(User *u) { diff --git a/src/login/logind-user.h b/src/login/logind-user.h index ad1686ffc5c..c3452dcd08f 100644 --- a/src/login/logind-user.h +++ b/src/login/logind-user.h @@ -66,7 +66,7 @@ User *user_free(User *u); DEFINE_TRIVIAL_CLEANUP_FUNC(User *, user_free); -bool user_check_gc(User *u, bool drop_not_started); +bool user_may_gc(User *u, bool drop_not_started); void user_add_to_gc_queue(User *u); int user_start(User *u); int user_stop(User *u, bool force); diff --git a/src/login/logind.c b/src/login/logind.c index d9b5f026cff..3a6ab7fcb6d 100644 --- a/src/login/logind.c +++ b/src/login/logind.c @@ -958,7 +958,7 @@ static void manager_gc(Manager *m, bool drop_not_started) { LIST_REMOVE(gc_queue, m->seat_gc_queue, seat); seat->in_gc_queue = false; - if (!seat_check_gc(seat, drop_not_started)) { + if (seat_may_gc(seat, drop_not_started)) { seat_stop(seat, false); seat_free(seat); } @@ -969,14 +969,14 @@ static void manager_gc(Manager *m, bool drop_not_started) { session->in_gc_queue = false; /* First, if we are not closing yet, initiate stopping */ - if (!session_check_gc(session, drop_not_started) && + if (session_may_gc(session, drop_not_started) && session_get_state(session) != SESSION_CLOSING) session_stop(session, false); /* Normally, this should make the session referenced * again, if it doesn't then let's get rid of it * immediately */ - if (!session_check_gc(session, drop_not_started)) { + if (session_may_gc(session, drop_not_started)) { session_finalize(session); session_free(session); } @@ -987,11 +987,11 @@ static void manager_gc(Manager *m, bool drop_not_started) { user->in_gc_queue = false; /* First step: queue stop jobs */ - if (!user_check_gc(user, drop_not_started)) + if (user_may_gc(user, drop_not_started)) user_stop(user, false); /* Second step: finalize user */ - if (!user_check_gc(user, drop_not_started)) { + if (user_may_gc(user, drop_not_started)) { user_finalize(user); user_free(user); }