From c372d14055b35a43a4619449e855313750c7f49b Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Tue, 4 Sep 2018 08:12:34 +0200 Subject: [PATCH 1/2] local-disp-factory: Remove initial VT is in use check The initial VT is in use check in on_vt_changed() is racy, when switching to VT1 from an active session, on_vt_changed() may run before logind has processed the VT change and then sd_seat_get_active() will return the active session which we are switching away from. This results in the greeter not being started on VT1. On my system gdm reliably wins the race resulting in not getting a greeter when manually switching from an active session to VT1. Unfortunately There is no way to fix this race. gdm already starts the greeter unconditionally from gdm_local_display_factory_sync_seats() on both startup and when an user session exits. gdm also starts it unconditionally when selecting "Switch user" from an user session. So we already have (and always have had) the assumption that the initial VT is free for gdm's use. And create_display already checks for and re-uses an existing greeter, so we can safely remove the racy check. --- daemon/gdm-local-display-factory.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/daemon/gdm-local-display-factory.c b/daemon/gdm-local-display-factory.c index c15a9a659..b78c82483 100644 --- a/daemon/gdm-local-display-factory.c +++ b/daemon/gdm-local-display-factory.c @@ -766,19 +766,6 @@ on_vt_changed (GIOChannel *source, return G_SOURCE_CONTINUE; } - ret = sd_seat_get_active ("seat0", &active_session_id, NULL); - - if (ret == 0) { - g_autofree char *state = NULL; - ret = sd_session_get_state (active_session_id, &state); - - /* if there's something already running on the active VT then bail */ - if (ret == 0 && g_strcmp0 (state, "closing") != 0) { - g_debug ("GdmLocalDisplayFactory: initial VT is in use, so ignoring"); - return G_SOURCE_CONTINUE; - } - } - if (gdm_local_display_factory_use_wayland ()) session_type = "wayland"; -- GitLab From 33c4708ad32156dcfef2d626a8fcfecec84802f8 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Tue, 4 Sep 2018 08:28:04 +0200 Subject: [PATCH 2/2] local-disp-factory: create_display: If we re-use a display clear the waiting-to-finish-status We may end up re-using a display in waiting-to-finish state before it gets finished in this case reset its state to managed to avoid it getting finished while it is being used. --- daemon/gdm-local-display-factory.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/daemon/gdm-local-display-factory.c b/daemon/gdm-local-display-factory.c index b78c82483..c43531e9d 100644 --- a/daemon/gdm-local-display-factory.c +++ b/daemon/gdm-local-display-factory.c @@ -447,6 +447,8 @@ create_display (GdmLocalDisplayFactory *factory, /* Ensure we don't create the same display more than once */ if (display != NULL) { g_debug ("GdmLocalDisplayFactory: display already created"); + if (gdm_display_get_status (display) == GDM_DISPLAY_WAITING_TO_FINISH) + g_object_set (G_OBJECT (display), "status", GDM_DISPLAY_MANAGED, NULL); return NULL; } @@ -462,7 +464,10 @@ create_display (GdmLocalDisplayFactory *factory, display = gdm_display_store_find (store, lookup_by_session_id, (gpointer) login_session_id); - if (display != NULL && gdm_display_get_status (display) == GDM_DISPLAY_MANAGED) { + if (display != NULL && + (gdm_display_get_status (display) == GDM_DISPLAY_MANAGED || + gdm_display_get_status (display) == GDM_DISPLAY_WAITING_TO_FINISH)) { + g_object_set (G_OBJECT (display), "status", GDM_DISPLAY_MANAGED, NULL); if (g_strcmp0 (active_session_id, login_session_id) != 0) { g_debug ("GdmLocalDisplayFactory: session %s found, activating.", login_session_id); -- GitLab