~leon_plickat/wlclock

0282c36a1b82c0d006c8566e021cf50b7544e94b — Leon Henrik Plickat 9 months ago 82a8511
Fix Wayland event flushing

Before this patch, the flush loop could get stuck
1 files changed, 14 insertions(+), 11 deletions(-)

M src/wlclock.c
M src/wlclock.c => src/wlclock.c +14 -11
@@ 592,18 592,21 @@ static void clock_run ()

	while (context.loop)
	{
		/* Flush Wayland events. */
		errno = 0;
		do {
			if ( wl_display_flush(context.display) == 1 && errno != EAGAIN )
			{
				clocklog(0, "ERROR: wl_display_flush: %s\n",
						strerror(errno));
				break;
			}
		} while ( errno == EAGAIN );
		/* Flush pending Wayland events/requests. */
		int ret = 1;
		while ( ret > 0 )
		{
			ret = wl_display_dispatch_pending(context.display);
			wl_display_flush(context.display);
		}
		if ( ret < 0 )
		{
			clocklog(0, "ERROR: wl_display_dispatch_pending: %s\n", strerror(errno));
			context.ret = EXIT_FAILURE;
			goto exit;
		}

		int ret = poll(fds, 1, get_timeout());
		ret = poll(fds, 1, get_timeout());

		if ( ret == 0 ) /* Timeout -> update clock hands. */
		{