diff options
author | Scott Moreau <oreaus@gmail.com> | 2020-06-30 10:10:23 -0600 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-06-30 21:21:25 +0200 |
commit | b1a47245a12356b048bd6c8841ebbdd2ae0b145f (patch) | |
tree | 90ac014e7e5a42c1c2a87079af0507258d8372c7 /xwayland/xwm.c | |
parent | 84d2f30faae963cdf9ec32ec015428c867ad1049 (diff) |
xwm: Destroy xwm on hangup or error
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.
Diffstat (limited to 'xwayland/xwm.c')
-rw-r--r-- | xwayland/xwm.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/xwayland/xwm.c b/xwayland/xwm.c index 6846c76f..a0ff4d90 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -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++; @@ -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); } |