[Mesa-dev] [PATCH] wayland: Don't cancel a roundtrip when any event is received

Kristian Høgsberg hoegsberg at gmail.com
Thu Jan 3 08:46:07 PST 2013


On Tue, Dec 25, 2012 at 01:01:08PM +0100, Jonas Ådahl wrote:
> Since wl_display_dispatch_queue() returns the number of processed events
> or -1 on error, only cancel the roundtrip if an -1 is returned.
> 
> This also fixes a potential memory corruption bug happening when the
> roundtrip does an early return and the callback later writes to the then
> out of scope stack allocated `done' parameter.
> ---
> 
> Hi,
> 
> This is the same fix as in
> http://lists.freedesktop.org/archives/wayland-devel/2012-November/006446.html

Yes, very nice, committed.

Kristian

> Jonas
> 
> 
>  src/egl/drivers/dri2/platform_wayland.c                 |    3 +++
>  src/gallium/state_trackers/egl/wayland/native_wayland.c |    5 ++++-
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
> index ba54286..10a0f08 100644
> --- a/src/egl/drivers/dri2/platform_wayland.c
> +++ b/src/egl/drivers/dri2/platform_wayland.c
> @@ -70,6 +70,9 @@ roundtrip(struct dri2_egl_display *dri2_dpy)
>     while (ret != -1 && !done)
>        ret = wl_display_dispatch_queue(dri2_dpy->wl_dpy, dri2_dpy->wl_queue);
>  
> +   if (!done)
> +      wl_callback_destroy(callback);
> +
>     return ret;
>  }
>  
> diff --git a/src/gallium/state_trackers/egl/wayland/native_wayland.c b/src/gallium/state_trackers/egl/wayland/native_wayland.c
> index 560e40d..941a094 100644
> --- a/src/gallium/state_trackers/egl/wayland/native_wayland.c
> +++ b/src/gallium/state_trackers/egl/wayland/native_wayland.c
> @@ -57,9 +57,12 @@ wayland_roundtrip(struct wayland_display *display)
>     callback = wl_display_sync(display->dpy);
>     wl_callback_add_listener(callback, &sync_listener, &done);
>     wl_proxy_set_queue((struct wl_proxy *) callback, display->queue);
> -   while (ret == 0 && !done)
> +   while (ret != -1 && !done)
>        ret = wl_display_dispatch_queue(display->dpy, display->queue);
>  
> +   if (!done)
> +      wl_callback_destroy(callback);
> +
>     return ret;
>  }
>  
> -- 
> 1.7.10.4
> 


More information about the mesa-dev mailing list