From 388702c181829a99b1540eeea734dc496f62f7f4 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Mon, 1 May 2023 19:20:32 +0100 Subject: [PATCH] frontend: Explicitly destroy Xwayland from frontend code Currently Xwayland is cleaned up by a destroy listener. The problem with this is that this is true for both libweston's Xwayland support as well as the frontend's. Add an explicit destroy step to Xwayland frontend which will cleanly destroy the process as well as any other resources. Signed-off-by: Daniel Stone --- compositor/main.c | 3 +++ compositor/weston.h | 3 +++ compositor/xwayland.c | 24 +++++++----------------- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/compositor/main.c b/compositor/main.c index 87e393bb6..ca009da2f 100644 --- a/compositor/main.c +++ b/compositor/main.c @@ -4190,6 +4190,9 @@ out: if (protologger) wl_protocol_logger_destroy(protologger); + if (wet_xwl) + wet_xwayland_destroy(wet.compositor, wet_xwl); + weston_compositor_destroy(wet.compositor); wet_compositor_destroy_layout(&wet); weston_log_scope_destroy(protocol_scope); diff --git a/compositor/weston.h b/compositor/weston.h index 2e9dd41ec..821ae6960 100644 --- a/compositor/weston.h +++ b/compositor/weston.h @@ -91,6 +91,9 @@ wet_get_bindir_path(const char *name); void * wet_load_xwayland(struct weston_compositor *comp); +void +wet_xwayland_destroy(struct weston_compositor *comp, void *data); + struct text_backend; struct text_backend * diff --git a/compositor/xwayland.c b/compositor/xwayland.c index 160c2ef4a..b83de09ba 100644 --- a/compositor/xwayland.c +++ b/compositor/xwayland.c @@ -48,7 +48,6 @@ struct wet_xwayland { struct weston_compositor *compositor; - struct wl_listener compositor_destroy_listener; const struct weston_xwayland_api *api; struct weston_xwayland *xwayland; struct wl_event_source *display_fd_source; @@ -219,21 +218,15 @@ err: return NULL; } -static void -wxw_compositor_destroy(struct wl_listener *listener, void *data) +void +wet_xwayland_destroy(struct weston_compositor *comp, void *data) { - struct wet_xwayland *wxw = - wl_container_of(listener, wxw, compositor_destroy_listener); + struct wet_xwayland *wxw = data; - wl_list_remove(&wxw->compositor_destroy_listener.link); - - /* Don't call xserver_exited because Xwayland's own destroy handler - * already does this for us ... */ - if (wxw->process) { - kill(wxw->process->pid, SIGTERM); - wl_list_remove(&wxw->process->link); - free(wxw->process); - } + /* Calling this will call the process cleanup, in turn cleaning up the + * client and the core Xwayland state */ + if (wxw->process) + wet_process_destroy(wxw->process, 0, true); free(wxw); } @@ -267,11 +260,8 @@ wet_load_xwayland(struct weston_compositor *comp) wxw->compositor = comp; wxw->api = api; wxw->xwayland = xwayland; - wxw->compositor_destroy_listener.notify = wxw_compositor_destroy; if (api->listen(xwayland, wxw, spawn_xserver) < 0) return NULL; - wl_signal_add(&comp->destroy_signal, &wxw->compositor_destroy_listener); - return wxw; }