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 <daniels@collabora.com>
This commit is contained in:
Daniel Stone 2023-05-01 19:20:32 +01:00
parent 10f6b99ac0
commit 388702c181
3 changed files with 13 additions and 17 deletions

View File

@ -4190,6 +4190,9 @@ out:
if (protologger) if (protologger)
wl_protocol_logger_destroy(protologger); wl_protocol_logger_destroy(protologger);
if (wet_xwl)
wet_xwayland_destroy(wet.compositor, wet_xwl);
weston_compositor_destroy(wet.compositor); weston_compositor_destroy(wet.compositor);
wet_compositor_destroy_layout(&wet); wet_compositor_destroy_layout(&wet);
weston_log_scope_destroy(protocol_scope); weston_log_scope_destroy(protocol_scope);

View File

@ -91,6 +91,9 @@ wet_get_bindir_path(const char *name);
void * void *
wet_load_xwayland(struct weston_compositor *comp); wet_load_xwayland(struct weston_compositor *comp);
void
wet_xwayland_destroy(struct weston_compositor *comp, void *data);
struct text_backend; struct text_backend;
struct text_backend * struct text_backend *

View File

@ -48,7 +48,6 @@
struct wet_xwayland { struct wet_xwayland {
struct weston_compositor *compositor; struct weston_compositor *compositor;
struct wl_listener compositor_destroy_listener;
const struct weston_xwayland_api *api; const struct weston_xwayland_api *api;
struct weston_xwayland *xwayland; struct weston_xwayland *xwayland;
struct wl_event_source *display_fd_source; struct wl_event_source *display_fd_source;
@ -219,21 +218,15 @@ err:
return NULL; return NULL;
} }
static void void
wxw_compositor_destroy(struct wl_listener *listener, void *data) wet_xwayland_destroy(struct weston_compositor *comp, void *data)
{ {
struct wet_xwayland *wxw = struct wet_xwayland *wxw = data;
wl_container_of(listener, wxw, compositor_destroy_listener);
wl_list_remove(&wxw->compositor_destroy_listener.link); /* Calling this will call the process cleanup, in turn cleaning up the
* client and the core Xwayland state */
/* Don't call xserver_exited because Xwayland's own destroy handler if (wxw->process)
* already does this for us ... */ wet_process_destroy(wxw->process, 0, true);
if (wxw->process) {
kill(wxw->process->pid, SIGTERM);
wl_list_remove(&wxw->process->link);
free(wxw->process);
}
free(wxw); free(wxw);
} }
@ -267,11 +260,8 @@ wet_load_xwayland(struct weston_compositor *comp)
wxw->compositor = comp; wxw->compositor = comp;
wxw->api = api; wxw->api = api;
wxw->xwayland = xwayland; wxw->xwayland = xwayland;
wxw->compositor_destroy_listener.notify = wxw_compositor_destroy;
if (api->listen(xwayland, wxw, spawn_xserver) < 0) if (api->listen(xwayland, wxw, spawn_xserver) < 0)
return NULL; return NULL;
wl_signal_add(&comp->destroy_signal, &wxw->compositor_destroy_listener);
return wxw; return wxw;
} }