dryang / rpms / systemd

Forked from rpms/systemd a year ago
Clone
b677e7
From 35f9a7f8f4e8917725349fe764706658c02537ca Mon Sep 17 00:00:00 2001
b677e7
From: Lennart Poettering <lennart@poettering.net>
b677e7
Date: Mon, 6 Aug 2018 19:02:29 +0200
b677e7
Subject: [PATCH] logind: never elect a session that is stopping as display
b677e7
b677e7
(cherry picked from commit 04857cd801022d9f9933efb484c6253572f09870)
b677e7
b677e7
Related: #1642460
b677e7
---
b677e7
 src/login/logind-user.c | 10 ++++------
b677e7
 1 file changed, 4 insertions(+), 6 deletions(-)
b677e7
b677e7
diff --git a/src/login/logind-user.c b/src/login/logind-user.c
b677e7
index 35b2ca5489..3e4c99bdbd 100644
b677e7
--- a/src/login/logind-user.c
b677e7
+++ b/src/login/logind-user.c
b677e7
@@ -613,11 +613,10 @@ int user_kill(User *u, int signo) {
b677e7
 }
b677e7
 
b677e7
 static bool elect_display_filter(Session *s) {
b677e7
-        /* Return true if the session is a candidate for the user’s ‘primary
b677e7
-         * session’ or ‘display’. */
b677e7
+        /* Return true if the session is a candidate for the user’s ‘primary session’ or ‘display’. */
b677e7
         assert(s);
b677e7
 
b677e7
-        return (s->class == SESSION_USER && !s->stopping);
b677e7
+        return s->class == SESSION_USER && s->started && !s->stopping;
b677e7
 }
b677e7
 
b677e7
 static int elect_display_compare(Session *s1, Session *s2) {
b677e7
@@ -663,9 +662,8 @@ void user_elect_display(User *u) {
b677e7
 
b677e7
         assert(u);
b677e7
 
b677e7
-        /* This elects a primary session for each user, which we call
b677e7
-         * the "display". We try to keep the assignment stable, but we
b677e7
-         * "upgrade" to better choices. */
b677e7
+        /* This elects a primary session for each user, which we call the "display". We try to keep the assignment
b677e7
+         * stable, but we "upgrade" to better choices. */
b677e7
         log_debug("Electing new display for user %s", u->name);
b677e7
 
b677e7
         LIST_FOREACH(sessions_by_user, s, u->sessions) {