Blame SOURCES/0003-manager-don-t-bail-if-session-disappears-out-from-un.patch

765e07
From 64779fcad9efa9fdb4b1a8963e2386cf763e53d8 Mon Sep 17 00:00:00 2001
765e07
From: Ray Strode <rstrode@redhat.com>
765e07
Date: Fri, 22 Jun 2018 15:26:03 -0400
4f3de9
Subject: [PATCH 3/7] manager: don't bail if session disappears out from under
765e07
 us
765e07
765e07
It's entirely possible for a session returned by
765e07
sd_seat_get_sessions to disappear immediately after the
765e07
sd_seat_get_sessions call returns.  This is especially
765e07
likely at logout time where the session will briefly be
765e07
in the "closing" state before getting reaped.
765e07
765e07
If that happens when we're looking for a greeter session, we
765e07
stop looking for a greeter session and bail out all confused.
765e07
765e07
This commit fixes the confusion by gracefully handling the
765e07
session disappearing by just proceeding to the next session
765e07
in the list.
765e07
---
765e07
 daemon/gdm-manager.c | 9 +++++++++
765e07
 1 file changed, 9 insertions(+)
765e07
765e07
diff --git a/daemon/gdm-manager.c b/daemon/gdm-manager.c
765e07
index 3f5772e65..c391307fa 100644
765e07
--- a/daemon/gdm-manager.c
765e07
+++ b/daemon/gdm-manager.c
765e07
@@ -1318,87 +1318,96 @@ maybe_start_pending_initial_login (GdmManager *manager,
765e07
         g_free (user_session_seat_id);
765e07
 }
765e07
 
765e07
 static gboolean
765e07
 get_login_window_session_id (const char  *seat_id,
765e07
                              char       **session_id)
765e07
 {
765e07
         gboolean   ret;
765e07
         int        res, i;
765e07
         char     **sessions;
765e07
         char      *service_id;
765e07
         char      *service_class;
765e07
         char      *state;
765e07
 
765e07
         res = sd_seat_get_sessions (seat_id, &sessions, NULL, NULL);
765e07
         if (res < 0) {
765e07
                 g_debug ("Failed to determine sessions: %s", strerror (-res));
765e07
                 return FALSE;
765e07
         }
765e07
 
765e07
         if (sessions == NULL || sessions[0] == NULL) {
765e07
                 *session_id = NULL;
765e07
                 ret = TRUE;
765e07
                 goto out;
765e07
         }
765e07
 
765e07
         for (i = 0; sessions[i]; i ++) {
765e07
 
765e07
                 res = sd_session_get_class (sessions[i], &service_class);
765e07
                 if (res < 0) {
765e07
+                        if (res == -ENOENT || res == -ENXIO) {
765e07
+                                continue;
765e07
+                        }
765e07
+
765e07
                         g_debug ("failed to determine class of session %s: %s", sessions[i], strerror (-res));
765e07
                         ret = FALSE;
765e07
                         goto out;
765e07
                 }
765e07
 
765e07
                 if (strcmp (service_class, "greeter") != 0) {
765e07
                         free (service_class);
765e07
                         continue;
765e07
                 }
765e07
 
765e07
                 free (service_class);
765e07
 
765e07
                 ret = sd_session_get_state (sessions[i], &state);
765e07
                 if (ret < 0) {
765e07
+                        if (res == -ENOENT || res == -ENXIO)
765e07
+                                continue;
765e07
+
765e07
                         g_debug ("failed to determine state of session %s: %s", sessions[i], strerror (-res));
765e07
                         ret = FALSE;
765e07
                         goto out;
765e07
                 }
765e07
 
765e07
                 if (g_strcmp0 (state, "closing") == 0) {
765e07
                         free (state);
765e07
                         continue;
765e07
                 }
765e07
                 free (state);
765e07
 
765e07
                 res = sd_session_get_service (sessions[i], &service_id);
765e07
                 if (res < 0) {
765e07
+                        if (res == -ENOENT || res == -ENXIO)
765e07
+                                continue;
765e07
                         g_debug ("failed to determine service of session %s: %s", sessions[i], strerror (-res));
765e07
                         ret = FALSE;
765e07
                         goto out;
765e07
                 }
765e07
 
765e07
                 if (strcmp (service_id, "gdm-launch-environment") == 0) {
765e07
                         *session_id = g_strdup (sessions[i]);
765e07
                         ret = TRUE;
765e07
 
765e07
                         free (service_id);
765e07
                         goto out;
765e07
                 }
765e07
 
765e07
                 free (service_id);
765e07
         }
765e07
 
765e07
         *session_id = NULL;
765e07
         ret = TRUE;
765e07
 
765e07
 out:
765e07
         if (sessions) {
765e07
                 for (i = 0; sessions[i]; i ++) {
765e07
                         free (sessions[i]);
765e07
                 }
765e07
 
765e07
                 free (sessions);
765e07
         }
765e07
 
765e07
         return ret;
765e07
 }
765e07
-- 
765e07
2.19.0
765e07