From 83666d60c8d08b89bfd2299323156cb5eb94e2ef Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Thu, 30 Aug 2018 13:06:54 -0400 Subject: common: don't bail if session disappears out from under us It's entirely possible for a session returned by sd_seat_get_sessions to disappear immediately after the sd_seat_get_sessions call returns. This is especially likely at logout time where the session will briefly be in the "closing" state before getting reaped. If that happens when we're looking for a greeter session, we stop looking for a greeter session and bail out all confused. This commit fixes the confusion by gracefully handling the session disappearing by just proceeding to the next session in the list. This commit is very similar to commit 155ee7eca which got accidentally reverted during code consolidation. The main difference is this commit checks the correct error code of -ENXIO instead of -ENOENT, so it might actually fix what it's ostensibly supposed to fix. --- common/gdm-common.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/gdm-common.c b/common/gdm-common.c index 9683d557..373d5b85 100644 --- a/common/gdm-common.c +++ b/common/gdm-common.c @@ -408,7 +408,7 @@ gdm_get_login_window_session_id (const char *seat_id, res = sd_session_get_class (sessions[i], &service_class); if (res < 0) { - if (res == -ENOENT) + if (res == -ENXIO) continue; g_debug ("failed to determine class of session %s: %s", sessions[i], strerror (-res)); @@ -425,6 +425,9 @@ gdm_get_login_window_session_id (const char *seat_id, ret = sd_session_get_state (sessions[i], &state); if (ret < 0) { + if (res == -ENXIO) + continue; + g_debug ("failed to determine state of session %s: %s", sessions[i], strerror (-res)); ret = FALSE; goto out; @@ -438,6 +441,9 @@ gdm_get_login_window_session_id (const char *seat_id, res = sd_session_get_service (sessions[i], &service_id); if (res < 0) { + if (res == -ENXIO) + continue; + g_debug ("failed to determine service of session %s: %s", sessions[i], strerror (-res)); ret = FALSE; goto out; -- cgit v1.2.1