[gdm/wip/fix-double-greeters: 3/5] local-display-factory: add more debug messages to new vt handling code



commit 624388563f76214b0548e778866f664549e9df23
Author: Ray Strode <rstrode redhat com>
Date:   Tue Aug 7 13:55:06 2018 -0400

    local-display-factory: add more debug messages to new vt handling code
    
    commit c0188a7030 added some complex code for starting and stopping
    the login screen based on VT changes.
    
    That code currently has zero debug statements in it making it trickier
    than necessary to debug.
    
    This commit sprinkles some g_debug's throughout the function.

 daemon/gdm-local-display-factory.c | 43 ++++++++++++++++++++++++++++++--------
 1 file changed, 34 insertions(+), 9 deletions(-)
---
diff --git a/daemon/gdm-local-display-factory.c b/daemon/gdm-local-display-factory.c
index 8bf92b64..5126683f 100644
--- a/daemon/gdm-local-display-factory.c
+++ b/daemon/gdm-local-display-factory.c
@@ -552,8 +552,10 @@ maybe_stop_greeter_display (GdmDisplay *display)
 {
         g_autofree char *display_session_type = NULL;
 
-        if (gdm_display_get_status (display) != GDM_DISPLAY_MANAGED)
+        if (gdm_display_get_status (display) != GDM_DISPLAY_MANAGED) {
+                g_debug ("GdmLocalDisplayFactory: login window not in managed state, so ignoring");
                 return;
+        }
 
         g_object_get (G_OBJECT (display),
                       "session-type", &display_session_type,
@@ -561,9 +563,12 @@ maybe_stop_greeter_display (GdmDisplay *display)
 
         /* we can only stop greeter for wayland sessions, since
          * X server would jump back on exit */
-        if (g_strcmp0 (display_session_type, "wayland") != 0)
+        if (g_strcmp0 (display_session_type, "wayland") != 0) {
+                g_debug ("GdmLocalDisplayFactory: login window is running on Xorg, so ignoring");
                 return;
+        }
 
+        g_debug ("GdmLocalDisplayFactory: killing login window since its now unused");
         gdm_display_stop_greeter_session (display);
         gdm_display_unmanage (display);
         gdm_display_finish (display);
@@ -583,6 +588,7 @@ on_vt_changed (GIOChannel    *source,
         const char *session_type = NULL;
         int ret;
 
+        g_debug ("GdmLocalDisplayFactory: received VT change event");
         g_io_channel_seek_position (source, 0, G_SEEK_SET, NULL);
 
         if (condition & G_IO_PRI) {
@@ -604,21 +610,30 @@ on_vt_changed (GIOChannel    *source,
                 }
         }
 
-        if ((condition & G_IO_ERR) || (condition & G_IO_HUP))
+        if ((condition & G_IO_ERR) || (condition & G_IO_HUP)) {
+                g_debug ("GdmLocalDisplayFactory: kernel hung up active vt watch");
                 return G_SOURCE_REMOVE;
+        }
 
-        if (tty_of_active_vt == NULL)
+        if (tty_of_active_vt == NULL) {
+                g_debug ("GdmLocalDisplayFactory: unable to read active VT from kernel");
                 return G_SOURCE_CONTINUE;
+        }
 
         g_strchomp (tty_of_active_vt);
 
-        /* don't do anything if we're on the same VT we were before */
-        if (g_strcmp0 (tty_of_active_vt, factory->priv->tty_of_active_vt) == 0)
-                return G_SOURCE_CONTINUE;
-
         tty_of_previous_vt = g_steal_pointer (&factory->priv->tty_of_active_vt);
         factory->priv->tty_of_active_vt = g_steal_pointer (&tty_of_active_vt);
 
+        /* don't do anything at start up */
+        if (tty_of_previous_vt == NULL) {
+                g_debug ("GdmLocalDisplayFactory: VT changed as part of startup, ignoring");
+                return G_SOURCE_CONTINUE;
+        }
+
+        g_debug ("GdmLocalDisplayFactory: VT changed from %s to %s",
+                 tty_of_previous_vt, tty_of_active_vt);
+
         /* if the old VT was running a wayland login screen kill it
          */
         if (gdm_get_login_window_session_id ("seat0", &login_session_id)) {
@@ -630,10 +645,13 @@ on_vt_changed (GIOChannel    *source,
 
                         tty_of_login_window_vt = g_strdup_printf ("tty%u", vt);
 
+                        g_debug ("GdmLocalDisplayFactory: tty of login window is %s", 
tty_of_login_window_vt);
                         if (g_strcmp0 (tty_of_login_window_vt, tty_of_previous_vt) == 0) {
                                 GdmDisplayStore *store;
                                 GdmDisplay *display;
 
+                                g_debug ("GdmLocalDisplayFactory: VT switched from login window");
+
                                 store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY 
(factory));
                                 display = gdm_display_store_find (store,
                                                                   lookup_by_session_id,
@@ -641,6 +659,8 @@ on_vt_changed (GIOChannel    *source,
 
                                 if (display != NULL)
                                         maybe_stop_greeter_display (display);
+                        } else {
+                                g_debug ("GdmLocalDisplayFactory: VT not switched from login window");
                         }
                 }
         }
@@ -650,6 +670,7 @@ on_vt_changed (GIOChannel    *source,
          * jump to that login screen)
          */
         if (strcmp (factory->priv->tty_of_active_vt, tty_of_initial_vt) != 0) {
+                g_debug ("GdmLocalDisplayFactory: active VT is not initial VT, so ignoring");
                 return G_SOURCE_CONTINUE;
         }
 
@@ -660,13 +681,17 @@ on_vt_changed (GIOChannel    *source,
                 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)
+                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";
 
+        g_debug ("GdmLocalDisplayFactory: creating new display on seat0 because of VT change");
+
         create_display (factory, "seat0", session_type, TRUE);
 
         return G_SOURCE_CONTINUE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]