[PATCH v3] client: check for error in wl_display_read_events

Pekka Paalanen ppaalanen at gmail.com
Fri Aug 22 05:35:23 PDT 2014


On Fri, 22 Aug 2014 14:28:59 +0200
Marek Chalupa <mchqwerty at gmail.com> wrote:

> This prevents from blocking shown in one display test. Also, it
> makes sense to not proceed further in the code of the function
> when an error ocurred.
> 
> v2. set errno
>     put note about the errno into wl_display_prepare_read doc
>     check for error with mutex locked
> 
> v3.
>     set errno to display->last_error
> 
>     check for the error only in wl_display_read_events. It's sufficient
>     as prevention for the hanging and programmer doesn't need to
>     check if wl_display_prepare_read (that was previously covered by
>     this patch too) returned an error or the queue just was not empty.
>     Without the check, it could result in indefinite looping.
> 
> Thanks to Pekka Paalanen <pekka.paalanen at collabora.co.uk> for
> constant reviewing and discussing this patch.
> 
> Signed-off-by: Marek Chalupa <mchqwerty at gmail.com>
> ---
>  src/wayland-client.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/src/wayland-client.c b/src/wayland-client.c
> index 0f3f3d9..9159ee0 100644
> --- a/src/wayland-client.c
> +++ b/src/wayland-client.c
> @@ -1200,6 +1200,13 @@ wl_display_read_events(struct wl_display *display)
>  
>  	pthread_mutex_lock(&display->mutex);
>  
> +	if (display->last_error) {
> +		pthread_mutex_unlock(&display->mutex);
> +
> +		errno = display->last_error;
> +		return -1;
> +	}
> +
>  	ret = read_events(display);
>  
>  	pthread_mutex_unlock(&display->mutex);

Nailed!

Thanks,
pq


More information about the wayland-devel mailing list