[mutter/gnome-41] xwayland: Don't remove /tmp/.X11-unix/X0 when running tests



commit cd6abd5030a08c92b1643d8547e4d59e3fb827be
Author: Jonas Ådahl <jadahl gmail com>
Date:   Wed Dec 15 17:11:10 2021 +0100

    xwayland: Don't remove /tmp/.X11-unix/X0 when running tests
    
    When Xwayland was not initalized, we'd still clean things up. What this
    accidentally meant was that the uninitialized display number 0 was
    cleanud up, which very likely was main display of the host session.
    
    What this meant in practice was that /tmp/.X11-unix/X0 was often
    removed, causing every Flatpak X11 application to fail to start until
    Xwayland was restarted nad the X0 socket file was restored.
    
    Fix this in two ways: firstly only shutdown Xwayland if we ever started
    it, i.e. if the X11 display policy was not 'disabled'. This should fix
    the issue most of the times. Secondly only clean up the socket if it was
    ever initialized. This should fix things if the socket creation failed,
    as if it did, the name would be set.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2162>
    (cherry picked from commit 0df12ebee62de06262da5b6d297d7ace44ad9938)

 src/wayland/meta-wayland.c  |  7 ++++++-
 src/wayland/meta-xwayland.c | 23 ++++++++++++++---------
 2 files changed, 20 insertions(+), 10 deletions(-)
---
diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c
index ceb2afed35..aeccbfe385 100644
--- a/src/wayland/meta-wayland.c
+++ b/src/wayland/meta-wayland.c
@@ -414,7 +414,12 @@ meta_wayland_log_func (const char *fmt,
 void
 meta_wayland_compositor_prepare_shutdown (MetaWaylandCompositor *compositor)
 {
-  meta_xwayland_shutdown (&compositor->xwayland_manager);
+  MetaX11DisplayPolicy x11_display_policy;
+
+  x11_display_policy =
+    meta_context_get_x11_display_policy (compositor->context);
+  if (x11_display_policy != META_X11_DISPLAY_POLICY_DISABLED)
+    meta_xwayland_shutdown (&compositor->xwayland_manager);
 
   if (compositor->wayland_display)
     wl_display_destroy_clients (compositor->wayland_display);
diff --git a/src/wayland/meta-xwayland.c b/src/wayland/meta-xwayland.c
index 596c8209fe..9f1fac333d 100644
--- a/src/wayland/meta-xwayland.c
+++ b/src/wayland/meta-xwayland.c
@@ -1319,16 +1319,21 @@ meta_xwayland_shutdown (MetaXWaylandManager *manager)
 
   meta_xwayland_terminate (manager);
 
-  snprintf (path, sizeof path, "%s%d", X11_TMP_UNIX_PATH,
-            manager->public_connection.display_index);
-  unlink (path);
-
-  snprintf (path, sizeof path, "%s%d", X11_TMP_UNIX_PATH,
-            manager->private_connection.display_index);
-  unlink (path);
+  if (manager->public_connection.name)
+    {
+      snprintf (path, sizeof path, "%s%d", X11_TMP_UNIX_PATH,
+                manager->public_connection.display_index);
+      unlink (path);
+      g_clear_pointer (&manager->public_connection.name, g_free);
+    }
 
-  g_clear_pointer (&manager->public_connection.name, g_free);
-  g_clear_pointer (&manager->private_connection.name, g_free);
+  if (manager->private_connection.name)
+    {
+      snprintf (path, sizeof path, "%s%d", X11_TMP_UNIX_PATH,
+                manager->private_connection.display_index);
+      unlink (path);
+      g_clear_pointer (&manager->private_connection.name, g_free);
+    }
 
   meta_xwayland_connection_release (&manager->public_connection);
   meta_xwayland_connection_release (&manager->private_connection);


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