Improve error handling in wayland dispatch

rpi-vc4-hack
Andri Yngvason 2020-05-10 12:14:28 +00:00
parent 151e916752
commit 9b48290d09
1 changed files with 12 additions and 9 deletions

View File

@ -325,17 +325,20 @@ void on_wayland_event(void* obj)
{ {
struct wayvnc* self = aml_get_userdata(obj); struct wayvnc* self = aml_get_userdata(obj);
if (wl_display_prepare_read(self->display) < 0) { int rc = wl_display_prepare_read(self->display);
wl_display_cancel_read(self->display); assert(rc == 0);
return;
}
if (wl_display_read_events(self->display) < 0 && errno == EPIPE) { if (wl_display_read_events(self->display) < 0) {
if (errno == EPIPE) {
log_error("Compositor has gone away. Exiting...\n"); log_error("Compositor has gone away. Exiting...\n");
wayvnc_exit(self); wayvnc_exit(self);
} else {
log_error("Failed to read wayland events: %m\n");
}
} }
wl_display_dispatch_pending(self->display); if (wl_display_dispatch_pending(self->display) < 0)
log_error("Failed to dispatch pending\n");
} }
void wayvnc_exit(struct wayvnc* self) void wayvnc_exit(struct wayvnc* self)