From 0e8aaebc00f18a642c9058c00f5ea6f52cd2b385 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Sat, 28 May 2022 20:18:41 +0200 Subject: [PATCH] xwayland: Make XSetIOErrorExitHandler() mandatory Part-of: --- config.h.meson | 3 --- meson.build | 13 ++----------- src/wayland/meta-xwayland.c | 32 +++++++++++++------------------- 3 files changed, 15 insertions(+), 33 deletions(-) diff --git a/config.h.meson b/config.h.meson index c7724b24f..d7fd48f9b 100644 --- a/config.h.meson +++ b/config.h.meson @@ -95,9 +95,6 @@ /* Whether Xwayland has -listenfd option */ #mesondefine HAVE_XWAYLAND_LISTENFD -/* Whether libX11 has XSetIOErrorExitHandler */ -#mesondefine HAVE_XSETIOERROREXITHANDLER - /* Whether the mkostemp function exists */ #mesondefine HAVE_MKOSTEMP diff --git a/meson.build b/meson.build index 56ae4b807..43ea293dd 100644 --- a/meson.build +++ b/meson.build @@ -28,6 +28,7 @@ cairo_req = '>= 1.10.0' pangocairo_req = '>= 1.20' gsettings_desktop_schemas_req = '>= 40.alpha' json_glib_req = '>= 0.12.0' +x11_req = '>= 1.7.0' xcomposite_req = '>= 0.4' xkbcommon_req = '>= 0.4.3' xfixes_req = '>= 6' @@ -145,7 +146,7 @@ if not have_wayland and not have_x11 endif if have_x11_client - x11_dep = dependency('x11') + x11_dep = dependency('x11', version: x11_req) xcomposite_dep = dependency('xcomposite', version: xcomposite_req) xcursor_dep = dependency('xcursor') xdamage_dep = dependency('xdamage') @@ -591,15 +592,6 @@ if have_xwayland endif endif -have_xsetioerrorexithandler = false -if have_x11_client - if cc.has_function('XSetIOErrorExitHandler', dependencies: x11_dep, - prefix: '''#include ''') - have_xsetioerrorexithandler = true - cdata.set('HAVE_XSETIOERROREXITHANDLER', 1) - endif -endif - optional_functions = [ 'mkostemp', 'posix_fallocate', @@ -678,7 +670,6 @@ summary('Documentation', have_documentation, section: 'Options') summary('Profiler', have_profiler, section: 'Options') summary('Xwayland initfd', have_xwayland_initfd, section: 'Options') summary('Xwayland listenfd', have_xwayland_listenfd, section: 'Options') -summary('Safe X11 I/O errors', have_xsetioerrorexithandler, section: 'Options') summary('Xwayland terminate delay', have_xwayland_terminate_delay, section: 'Options') summary('Enabled', have_tests, section: 'Tests') diff --git a/src/wayland/meta-xwayland.c b/src/wayland/meta-xwayland.c index 44229eac0..a937f0ec8 100644 --- a/src/wayland/meta-xwayland.c +++ b/src/wayland/meta-xwayland.c @@ -455,16 +455,8 @@ meta_xwayland_terminate (MetaXWaylandManager *manager) static int x_io_error (Display *display) { - MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default (); - MetaX11DisplayPolicy x11_display_policy; - g_warning ("Connection to xwayland lost"); - x11_display_policy = - meta_context_get_x11_display_policy (compositor->context); - if (x11_display_policy == META_X11_DISPLAY_POLICY_MANDATORY) - meta_exit (META_EXIT_ERROR); - return 0; } @@ -474,21 +466,30 @@ x_io_error_noop (Display *display) return 0; } -#ifdef HAVE_XSETIOERROREXITHANDLER static void x_io_error_exit (Display *display, void *data) { MetaXWaylandManager *manager = data; + MetaContext *context = manager->compositor->context; MetaX11DisplayPolicy x11_display_policy; x11_display_policy = - meta_context_get_x11_display_policy (manager->compositor->context); + meta_context_get_x11_display_policy (context); if (x11_display_policy == META_X11_DISPLAY_POLICY_MANDATORY) - g_warning ("X Wayland crashed (X IO error)"); + { + GError *error; + + g_warning ("Xwayland terminated, exiting since it was mandatory"); + error = g_error_new (G_IO_ERROR, G_IO_ERROR_FAILED, + "Xwayland exited unexpectedly"); + meta_context_terminate_with_error (context, error); + } else - meta_topic (META_DEBUG_WAYLAND, "Xwayland disappeared"); + { + meta_topic (META_DEBUG_WAYLAND, "Xwayland disappeared"); + } } static void @@ -496,7 +497,6 @@ x_io_error_exit_noop (Display *display, void *data) { } -#endif void meta_xwayland_override_display_number (int number) @@ -1114,9 +1114,7 @@ meta_xwayland_setup_xdisplay (MetaXWaylandManager *manager, we won't reset the tty). */ XSetIOErrorHandler (x_io_error); -#ifdef HAVE_XSETIOERROREXITHANDLER XSetIOErrorExitHandler (xdisplay, x_io_error_exit, manager); -#endif XFixesSetClientDisconnectMode (xdisplay, XFixesClientDisconnectFlagTerminate); } @@ -1131,23 +1129,19 @@ meta_xwayland_connection_release (MetaXWaylandConnection *connection) void meta_xwayland_shutdown (MetaXWaylandManager *manager) { -#ifdef HAVE_XSETIOERROREXITHANDLER MetaDisplay *display = meta_get_display (); MetaX11Display *x11_display; -#endif char path[256]; g_cancellable_cancel (manager->xserver_died_cancellable); XSetIOErrorHandler (x_io_error_noop); -#ifdef HAVE_XSETIOERROREXITHANDLER x11_display = display->x11_display; if (x11_display) { XSetIOErrorExitHandler (meta_x11_display_get_xdisplay (x11_display), x_io_error_exit_noop, NULL); } -#endif meta_xwayland_terminate (manager);