Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Commit

Permalink
xwm: Destroy xwm on hangup or error
Browse files Browse the repository at this point in the history
If Xwayland is restarted, the ready handler assumes there is no xwm instance.
This means all of xwm was leaked on Xwayland restart. This caused compositors
to consume all cpu resources, where time is spent dispatching. Now we destroy
xwm if we get an event mask containing WL_EVENT_HANGUP or WL_EVENT_ERROR.
  • Loading branch information
soreau authored and emersion committed Jun 30, 2020
1 parent 84d2f30 commit b1a4724
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions xwayland/xwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1312,6 +1312,11 @@ static int x11_event_handler(int fd, uint32_t mask, void *data) {
xcb_generic_event_t *event;
struct wlr_xwm *xwm = data;

if ((mask & WL_EVENT_HANGUP) || (mask & WL_EVENT_ERROR)) {
xwm_destroy(xwm);
return 0;
}

while ((event = xcb_poll_for_event(xwm->xcb_conn))) {
count++;

Expand Down Expand Up @@ -1493,6 +1498,7 @@ void xwm_destroy(struct wlr_xwm *xwm) {
wl_list_remove(&xwm->compositor_destroy.link);
xcb_disconnect(xwm->xcb_conn);

xwm->xwayland->xwm = NULL;
free(xwm);
}

Expand Down

0 comments on commit b1a4724

Please sign in to comment.