From cc9251d5c39ff3e4beb130306722d7b90d1031ab Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Mon, 23 Jan 2023 14:54:52 +0100 Subject: [PATCH] display_dispatch: Terminate poll loop on EPIPE display_dispatch tried to flush the display in a loop until it no longer returns an error that is EAGAIN or EPIPE. This becomes an infinite loop if the socket is closed. Stop flushing if we hit EPIPE, as the connection is dead. We still try to read what we were sent to the protocol error shows up in debug output. --- main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 95330bf..beb0782 100644 --- a/main.c +++ b/main.c @@ -634,8 +634,10 @@ static int display_dispatch(struct wl_display *display, int timeout) { pfd[1].fd = timer_signal_fds[0]; pfd[0].events = POLLOUT; - while (wl_display_flush(display) == -1) { - if (errno != EAGAIN && errno != EPIPE) { + // If we hit EPIPE we might have hit a protocol error. Continue reading + // so that we can see what happened. + while (wl_display_flush(display) == -1 && errno != EPIPE) { + if (errno != EAGAIN) { wl_display_cancel_read(display); return -1; } -- 2.45.2