From a9b1d9e83854eb589978e4d8bea9198f1198a45f Mon Sep 17 00:00:00 2001 From: Scott Moreau Date: Tue, 31 Dec 2019 02:46:27 -0700 Subject: [PATCH] xwayland: Clean up if Xwayland fails to start When running wlroots compositors with Xwayland executable bits unset, if DISPLAY is set to the display number wlroots has set up, then X and gtk clients (at least) hang when they are ran. X clients should fail with an error and exit while gtk clients should fall back to wayland backend and run correctly. This is because wlroots opened sockets for Xwayland but wasn't closing them if Xwayland failed to start. --- xwayland/xwayland.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/xwayland/xwayland.c b/xwayland/xwayland.c index 2018d341..77698f44 100644 --- a/xwayland/xwayland.c +++ b/xwayland/xwayland.c @@ -219,18 +219,17 @@ static int xserver_handle_ready(int signal_number, void *data) { continue; } wlr_log_errno(WLR_ERROR, "waitpid for Xwayland fork failed"); - return 1; + goto error; } if (stat_val) { wlr_log(WLR_ERROR, "Xwayland startup failed, not setting up xwm"); - return 1; + goto error; } wlr_log(WLR_DEBUG, "Xserver is ready"); wlr_xwayland->xwm = xwm_create(wlr_xwayland); if (!wlr_xwayland->xwm) { - xwayland_finish_server(wlr_xwayland); - return 1; + goto error; } if (wlr_xwayland->seat) { @@ -254,6 +253,13 @@ static int xserver_handle_ready(int signal_number, void *data) { wl_signal_init(&wlr_xwayland->events.ready); return 1; /* wayland event loop dispatcher's count */ +error: + /* clean up */ + wlr_xwayland_set_seat(wlr_xwayland, NULL); + xwayland_finish_server(wlr_xwayland); + xwayland_finish_display(wlr_xwayland); + + return 1; } static int xwayland_socket_connected(int fd, uint32_t mask, void* data){