[PATCH] event-loop: always do the post-dispatch check

Kristian Hoegsberg hoegsberg at gmail.com
Tue Mar 20 12:29:08 PDT 2012


On Tue, Mar 13, 2012 at 01:16:13PM +0200, Ander Conselvan de Oliveira wrote:
> The post-dispatch check on wl_event_loop_dispatch() was not being run
> if epoll_wait returned 0 events, making the check unreliable.
> ---
> 
> With the changes on Weston to process input during output repaint, this
> bug was actually preventing input to be processed on the X11 compositor
> while repaint was being called from weston_output_finish_frame().

Yeah, ouch, that's a really nasty bug.  I think you've got the right
fix here.  The problem is that we do something in one loop that may
cause a source in the other loop to have events, but now the
post_dispatch check in the first loop doesn't check the source in the
other loop.  I considered changing the way checked sources work so
that you have to mark the source as "potentially having events".  That
way the information stays with the source, not the loop.  We would
then do that in compositor-x11.c whenever we talk to X and when we
jump into the input loop, we would know whether or not to check the X
source.

Your patch is a lot simpler and probably less work overall, and a lot
less error prone.

thanks,
Kristian

>  src/event-loop.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/src/event-loop.c b/src/event-loop.c
> index 2dfe0ae..da7b02b 100644
> --- a/src/event-loop.c
> +++ b/src/event-loop.c
> @@ -462,8 +462,9 @@ wl_event_loop_dispatch(struct wl_event_loop *loop, int timeout)
>  		n += source->interface->dispatch(source, &ep[i]);
>  	}
>  
> -	while (n > 0)
> +	do {
>  		n = post_dispatch_check(loop);
> +	} while (n > 0);
>  		
>  	return 0;
>  }
> -- 
> 1.7.4.1
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list