chiark / gitweb /
logind: change check_gc to may_gc everywhere
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 15 Feb 2018 12:14:35 +0000 (13:14 +0100)
committerSven Eden <yamakuzure@gmx.net>
Wed, 30 May 2018 05:58:57 +0000 (07:58 +0200)
src/login/logind-seat.c
src/login/logind-seat.h
src/login/logind-session.c
src/login/logind-session.h
src/login/logind-user.c
src/login/logind-user.h
src/login/logind.c

index 996ea3e13050f509b2d0d6ac390543381962708a..3b1962ddd20fceb4b6ccd91f1715ca608c113031 100644 (file)
@@ -645,16 +645,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) {
index caf9708c15896a2aa4a12d30d3ce87592f45f38b..ed2df6bbe9bfb7cd1f3204139832bdd9ba0b6a61 100644 (file)
@@ -81,7 +81,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);
index 6a3b71ccce26c77934f33e8a5899bb05730a146a..f1e6d1dd70da7bd42bb39d1fdd6d31ef2281afbf 100644 (file)
@@ -1058,29 +1058,29 @@ 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 0 /// elogind supports neither scopes nor jobs
         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;
 #endif // 0
+                return false;
 
-        return false;
+        return true;
 }
 
 void session_add_to_gc_queue(Session *s) {
index d53975acc0246f265cb3d0ec0481551e3aa665ea..0e8401b721df2b5aed55447b7ce82d0073590d76 100644 (file)
@@ -133,7 +133,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);
index e64bb31ac424caa29c940e1bb317afde7b291b2f..15460224cdeab6d26a5073f506e40db29cf73898 100644 (file)
@@ -708,27 +708,27 @@ 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 0 /// elogind neither supports service nor slice jobs
         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;
 #endif // 0
+                return false;
 
-        return false;
+        return true;
 }
 
 void user_add_to_gc_queue(User *u) {
index cc8fb26b45b040e7413b8d0e2eafb3a6774b40bb..4d9707e7313974494906b2e159f1657b68acdb15 100644 (file)
@@ -68,7 +68,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);
index 356236178524c77c7d62f56155558409ddaa849b..cd6fa96cf0b786949f9fd8204f71590fd0a060e3 100644 (file)
@@ -999,7 +999,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);
                 }
@@ -1010,14 +1010,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);
                 }
@@ -1028,11 +1028,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);
                 }