aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-01-09 13:52:36 +0100
committerDrew DeVault <sir@cmpwn.com>2020-01-09 07:48:30 -0700
commit802ef9da8a1c3fa940d76c60f5bf635afa0b16fb (patch)
treea4061b3f0a3d21df04386e36110e1a6224f0cba5
parente6fd880686a1bec793eef16cd502ba41bde9a64e (diff)
backend/wayland: handle display errors more gracefully
Previously, an error on the remote Wayland display would result in an infinite loop priting: 2020-01-09 13:39:03 - [wayland] Source dispatch function returned negative value! 2020-01-09 13:39:03 - [wayland] This would previously accidentally suppress a follow-up dispatch This happens when the remote compositor disconnects the client because of a protocol error, for instance. Handle wl_display_dispatch and wl_display_dispatch_pending returning -1 by terminating the local display and printing an error.
-rw-r--r--backend/wayland/backend.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/backend/wayland/backend.c b/backend/wayland/backend.c
index c23be048..e5858158 100644
--- a/backend/wayland/backend.c
+++ b/backend/wayland/backend.c
@@ -34,24 +34,31 @@ static int dispatch_events(int fd, uint32_t mask, void *data) {
struct wlr_wl_backend *wl = data;
if ((mask & WL_EVENT_HANGUP) || (mask & WL_EVENT_ERROR)) {
+ if (mask & WL_EVENT_ERROR) {
+ wlr_log(WLR_ERROR, "Failed to read from remote Wayland display");
+ }
wl_display_terminate(wl->local_display);
return 0;
}
+ int count = 0;
if (mask & WL_EVENT_READABLE) {
- return wl_display_dispatch(wl->remote_display);
+ count = wl_display_dispatch(wl->remote_display);
}
if (mask & WL_EVENT_WRITABLE) {
wl_display_flush(wl->remote_display);
- return 0;
}
if (mask == 0) {
- int count = wl_display_dispatch_pending(wl->remote_display);
+ count = wl_display_dispatch_pending(wl->remote_display);
wl_display_flush(wl->remote_display);
- return count;
}
- return 0;
+ if (count < 0) {
+ wlr_log(WLR_ERROR, "Failed to dispatch remote Wayland display");
+ wl_display_terminate(wl->local_display);
+ return 0;
+ }
+ return count;
}
static void xdg_wm_base_handle_ping(void *data,