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.
master
Kenny Levinsen 2023-01-23 14:54:52 +01:00
parent cee422b440
commit cc9251d5c3
1 changed files with 4 additions and 2 deletions

6
main.c
View File

@ -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;
}