summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/logind-seat.c4
-rw-r--r--src/logind-seat.h2
-rw-r--r--src/logind-session.c4
-rw-r--r--src/logind-session.h2
-rw-r--r--src/logind-user.c4
-rw-r--r--src/logind-user.h2
-rw-r--r--src/logind.c15
-rw-r--r--src/logind.h2
8 files changed, 19 insertions, 16 deletions
diff --git a/src/logind-seat.c b/src/logind-seat.c
index b8f1f607d0..3cf3958c8d 100644
--- a/src/logind-seat.c
+++ b/src/logind-seat.c
@@ -446,10 +446,10 @@ int seat_get_idle_hint(Seat *s, dual_timestamp *t) {
return idle_hint;
}
-int seat_check_gc(Seat *s) {
+int seat_check_gc(Seat *s, bool drop_not_started) {
assert(s);
- if (!s->started)
+ if (drop_not_started && !s->started)
return 0;
if (seat_is_vtconsole(s))
diff --git a/src/logind-seat.h b/src/logind-seat.h
index 6d9c36db34..5bce1434e9 100644
--- a/src/logind-seat.h
+++ b/src/logind-seat.h
@@ -68,7 +68,7 @@ int seat_start(Seat *s);
int seat_stop(Seat *s);
int seat_stop_sessions(Seat *s);
-int seat_check_gc(Seat *s);
+int seat_check_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/logind-session.c b/src/logind-session.c
index 088e956bfc..3521309846 100644
--- a/src/logind-session.c
+++ b/src/logind-session.c
@@ -841,12 +841,12 @@ void session_remove_fifo(Session *s) {
}
}
-int session_check_gc(Session *s) {
+int session_check_gc(Session *s, bool drop_not_started) {
int r;
assert(s);
- if (!s->started)
+ if (drop_not_started && !s->started)
return 0;
if (s->fifo_fd >= 0) {
diff --git a/src/logind-session.h b/src/logind-session.h
index d0cf0ed886..303e61abdf 100644
--- a/src/logind-session.h
+++ b/src/logind-session.h
@@ -86,7 +86,7 @@ struct Session {
Session *session_new(Manager *m, User *u, const char *id);
void session_free(Session *s);
-int session_check_gc(Session *s);
+int session_check_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/logind-user.c b/src/logind-user.c
index 3076ed1573..dacf148f78 100644
--- a/src/logind-user.c
+++ b/src/logind-user.c
@@ -457,13 +457,13 @@ int user_get_idle_hint(User *u, dual_timestamp *t) {
return idle_hint;
}
-int user_check_gc(User *u) {
+int user_check_gc(User *u, bool drop_not_started) {
int r;
char *p;
assert(u);
- if (!u->started)
+ if (drop_not_started && !u->started)
return 0;
if (u->sessions)
diff --git a/src/logind-user.h b/src/logind-user.h
index dd0dcad9cf..8a8d5ede40 100644
--- a/src/logind-user.h
+++ b/src/logind-user.h
@@ -63,7 +63,7 @@ struct User {
User* user_new(Manager *m, uid_t uid, gid_t gid, const char *name);
void user_free(User *u);
-int user_check_gc(User *u);
+int user_check_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);
diff --git a/src/logind.c b/src/logind.c
index d7d04a2c53..9bab875131 100644
--- a/src/logind.c
+++ b/src/logind.c
@@ -975,7 +975,7 @@ static int manager_connect_udev(Manager *m) {
return 0;
}
-void manager_gc(Manager *m) {
+void manager_gc(Manager *m, bool drop_not_started) {
Seat *seat;
Session *session;
User *user;
@@ -986,7 +986,7 @@ void manager_gc(Manager *m) {
LIST_REMOVE(Seat, gc_queue, m->seat_gc_queue, seat);
seat->in_gc_queue = false;
- if (seat_check_gc(seat) == 0) {
+ if (seat_check_gc(seat, drop_not_started) == 0) {
seat_stop(seat);
seat_free(seat);
}
@@ -996,7 +996,7 @@ void manager_gc(Manager *m) {
LIST_REMOVE(Session, gc_queue, m->session_gc_queue, session);
session->in_gc_queue = false;
- if (session_check_gc(session) == 0) {
+ if (session_check_gc(session, drop_not_started) == 0) {
session_stop(session);
session_free(session);
}
@@ -1006,7 +1006,7 @@ void manager_gc(Manager *m) {
LIST_REMOVE(User, gc_queue, m->user_gc_queue, user);
user->in_gc_queue = false;
- if (user_check_gc(user) == 0) {
+ if (user_check_gc(user, drop_not_started) == 0) {
user_stop(user);
user_free(user);
}
@@ -1090,6 +1090,9 @@ int manager_startup(Manager *m) {
manager_enumerate_users(m);
manager_enumerate_sessions(m);
+ /* Remove stale objects before we start them */
+ manager_gc(m, false);
+
/* And start everything */
HASHMAP_FOREACH(seat, m->seats, i)
seat_start(seat);
@@ -1110,12 +1113,12 @@ int manager_run(Manager *m) {
struct epoll_event event;
int n;
- manager_gc(m);
+ manager_gc(m, true);
if (dbus_connection_dispatch(m->bus) != DBUS_DISPATCH_COMPLETE)
continue;
- manager_gc(m);
+ manager_gc(m, true);
n = epoll_wait(m->epoll_fd, &event, 1, -1);
if (n < 0) {
diff --git a/src/logind.h b/src/logind.h
index ebf859eb2e..8726502c1c 100644
--- a/src/logind.h
+++ b/src/logind.h
@@ -131,7 +131,7 @@ int manager_spawn_autovt(Manager *m, int vtnr);
void manager_cgroup_notify_empty(Manager *m, const char *cgroup);
-void manager_gc(Manager *m);
+void manager_gc(Manager *m, bool drop_not_started);
int manager_get_idle_hint(Manager *m, dual_timestamp *t);