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>
This commit is contained in:
Jonas Ådahl 2021-12-15 17:11:10 +01:00 committed by Marge Bot
parent f5f59ad6e6
commit 0df12ebee6
2 changed files with 20 additions and 10 deletions

View File

@ -421,7 +421,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);

View File

@ -1338,16 +1338,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);
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);
}
snprintf (path, sizeof path, "%s%d", X11_TMP_UNIX_PATH,
manager->private_connection.display_index);
unlink (path);
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);