Improve error handling in wayland dispatch
parent
151e916752
commit
9b48290d09
21
src/main.c
21
src/main.c
|
@ -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) {
|
||||||
|
if (errno == EPIPE) {
|
||||||
|
log_error("Compositor has gone away. Exiting...\n");
|
||||||
|
wayvnc_exit(self);
|
||||||
|
} else {
|
||||||
|
log_error("Failed to read wayland events: %m\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wl_display_read_events(self->display) < 0 && errno == EPIPE) {
|
if (wl_display_dispatch_pending(self->display) < 0)
|
||||||
log_error("Compositor has gone away. Exiting...\n");
|
log_error("Failed to dispatch pending\n");
|
||||||
wayvnc_exit(self);
|
|
||||||
}
|
|
||||||
|
|
||||||
wl_display_dispatch_pending(self->display);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wayvnc_exit(struct wayvnc* self)
|
void wayvnc_exit(struct wayvnc* self)
|
||||||
|
|
Loading…
Reference in New Issue