1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-31 16:21:26 +03:00

logind: change check_gc to may_gc everywhere

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2018-02-15 13:14:35 +01:00
parent f698d99cd5
commit 5c093a2368
7 changed files with 27 additions and 27 deletions

View File

@ -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;
if (seat_is_seat0(s))
return true;
return seat_has_master_device(s);
if (seat_is_seat0(s))
return false;
return !seat_has_master_device(s);
}
void seat_add_to_gc_queue(Seat *s) {

View File

@ -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);

View File

@ -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) {

View File

@ -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);

View File

@ -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) {

View File

@ -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);

View File

@ -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);
}