Do not destroy wl_client in wlr_xwayland_finish

This commit is contained in:
emersion 2017-12-08 01:38:45 +01:00
parent 18eb1eee3f
commit b06535718d
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
3 changed files with 39 additions and 25 deletions

View File

@ -23,7 +23,7 @@ struct wlr_xwayland {
time_t server_start; time_t server_start;
struct wl_event_source *sigusr1_source; struct wl_event_source *sigusr1_source;
struct wl_listener destroy_listener; struct wl_listener client_destroy;
struct wl_listener display_destroy; struct wl_listener display_destroy;
struct wlr_xwm *xwm; struct wlr_xwm *xwm;
struct wlr_xwayland_cursor *cursor; struct wlr_xwayland_cursor *cursor;

View File

@ -125,39 +125,26 @@ static void exec_xwayland(struct wlr_xwayland *wlr_xwayland) {
execvp("Xwayland", argv); execvp("Xwayland", argv);
} }
static bool wlr_xwayland_init(struct wlr_xwayland *wlr_xwayland,
struct wl_display *wl_display, struct wlr_compositor *compositor);
static void wlr_xwayland_finish(struct wlr_xwayland *wlr_xwayland);
static void xwayland_destroy_event(struct wl_listener *listener, void *data) {
struct wlr_xwayland *wlr_xwayland = wl_container_of(listener, wlr_xwayland, destroy_listener);
/* don't call client destroy */
wlr_xwayland->client = NULL;
wl_list_remove(&wlr_xwayland->destroy_listener.link);
wlr_xwayland_finish(wlr_xwayland);
if (time(NULL) - wlr_xwayland->server_start > 5) {
wlr_xwayland_init(wlr_xwayland, wlr_xwayland->wl_display,
wlr_xwayland->compositor);
}
}
static void wlr_xwayland_finish(struct wlr_xwayland *wlr_xwayland) { static void wlr_xwayland_finish(struct wlr_xwayland *wlr_xwayland) {
if (!wlr_xwayland || wlr_xwayland->display == -1) { if (!wlr_xwayland || wlr_xwayland->display == -1) {
return; return;
} }
if (wlr_xwayland->cursor != NULL) {
free(wlr_xwayland->cursor);
}
xwm_destroy(wlr_xwayland->xwm);
if (wlr_xwayland->client) { if (wlr_xwayland->client) {
wl_list_remove(&wlr_xwayland->destroy_listener.link); wl_list_remove(&wlr_xwayland->client_destroy.link);
wl_client_destroy(wlr_xwayland->client); // TODO: this segfaults in /usr/lib/libEGL_mesa.so.0
//wl_client_destroy(wlr_xwayland->client);
} }
if (wlr_xwayland->sigusr1_source) { if (wlr_xwayland->sigusr1_source) {
wl_event_source_remove(wlr_xwayland->sigusr1_source); wl_event_source_remove(wlr_xwayland->sigusr1_source);
} }
xwm_destroy(wlr_xwayland->xwm);
safe_close(wlr_xwayland->x_fd[0]); safe_close(wlr_xwayland->x_fd[0]);
safe_close(wlr_xwayland->x_fd[1]); safe_close(wlr_xwayland->x_fd[1]);
safe_close(wlr_xwayland->wl_fd[0]); safe_close(wlr_xwayland->wl_fd[0]);
@ -176,6 +163,24 @@ static void wlr_xwayland_finish(struct wlr_xwayland *wlr_xwayland) {
*/ */
} }
static bool wlr_xwayland_init(struct wlr_xwayland *wlr_xwayland,
struct wl_display *wl_display, struct wlr_compositor *compositor);
static void handle_client_destroy(struct wl_listener *listener, void *data) {
struct wlr_xwayland *wlr_xwayland =
wl_container_of(listener, wlr_xwayland, client_destroy);
/* don't call client destroy */
wlr_xwayland->client = NULL;
wl_list_remove(&wlr_xwayland->client_destroy.link);
wlr_xwayland_finish(wlr_xwayland);
if (time(NULL) - wlr_xwayland->server_start > 5) {
wlr_xwayland_init(wlr_xwayland, wlr_xwayland->wl_display,
wlr_xwayland->compositor);
}
}
static void handle_display_destroy(struct wl_listener *listener, void *data) { static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_xwayland *wlr_xwayland = struct wlr_xwayland *wlr_xwayland =
wl_container_of(listener, wlr_xwayland, display_destroy); wl_container_of(listener, wlr_xwayland, display_destroy);
@ -264,9 +269,9 @@ static bool wlr_xwayland_init(struct wlr_xwayland *wlr_xwayland,
wlr_xwayland->wl_fd[0] = -1; /* not ours anymore */ wlr_xwayland->wl_fd[0] = -1; /* not ours anymore */
wlr_xwayland->destroy_listener.notify = xwayland_destroy_event; wlr_xwayland->client_destroy.notify = handle_client_destroy;
wl_client_add_destroy_listener(wlr_xwayland->client, wl_client_add_destroy_listener(wlr_xwayland->client,
&wlr_xwayland->destroy_listener); &wlr_xwayland->client_destroy);
struct wl_event_loop *loop = wl_display_get_event_loop(wl_display); struct wl_event_loop *loop = wl_display_get_event_loop(wl_display);
wlr_xwayland->sigusr1_source = wl_event_loop_add_signal(loop, SIGUSR1, wlr_xwayland->sigusr1_source = wl_event_loop_add_signal(loop, SIGUSR1,

View File

@ -1045,6 +1045,12 @@ void xwm_destroy(struct wlr_xwm *xwm) {
if (xwm->cursor) { if (xwm->cursor) {
xcb_free_cursor(xwm->xcb_conn, xwm->cursor); xcb_free_cursor(xwm->xcb_conn, xwm->cursor);
} }
if (xwm->colormap) {
xcb_free_colormap(xwm->xcb_conn, xwm->colormap);
}
if (xwm->window) {
xcb_destroy_window(xwm->xcb_conn, xwm->window);
}
if (xwm->event_source) { if (xwm->event_source) {
wl_event_source_remove(xwm->event_source); wl_event_source_remove(xwm->event_source);
} }
@ -1052,6 +1058,9 @@ void xwm_destroy(struct wlr_xwm *xwm) {
wl_list_for_each_safe(xsurface, tmp, &xwm->surfaces, link) { wl_list_for_each_safe(xsurface, tmp, &xwm->surfaces, link) {
wlr_xwayland_surface_destroy(xsurface); wlr_xwayland_surface_destroy(xsurface);
} }
wl_list_for_each_safe(xsurface, tmp, &xwm->unpaired_surfaces, link) {
wlr_xwayland_surface_destroy(xsurface);
}
wl_list_remove(&xwm->compositor_surface_create.link); wl_list_remove(&xwm->compositor_surface_create.link);
xcb_disconnect(xwm->xcb_conn); xcb_disconnect(xwm->xcb_conn);