~kennylevinsen/wlsunset

cc9251d5c39ff3e4beb130306722d7b90d1031ab — Kenny Levinsen 1 year, 8 months ago cee422b
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.
1 files changed, 4 insertions(+), 2 deletions(-)

M main.c
M main.c => main.c +4 -2
@@ 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;
		}