[Mesa-dev] [PATCH v2] egl/wayland: Avoid race conditions when on non-main thread
Daniel Stone
daniel at fooishbar.org
Sun Oct 16 13:55:57 UTC 2016
Hi Jonas,
On 24 June 2016 at 03:46, Jonas Ã…dahl <jadahl at gmail.com> wrote:
> @@ -74,9 +74,8 @@ roundtrip(struct dri2_egl_display *dri2_dpy)
> struct wl_callback *callback;
> int done = 0, ret = 0;
>
> - callback = wl_display_sync(dri2_dpy->wl_dpy);
> + callback = wl_display_sync(dri2_dpy->wl_dpy_wrapper);
> wl_callback_add_listener(callback, &sync_listener, &done);
> - wl_proxy_set_queue((struct wl_proxy *) callback, dri2_dpy->wl_queue);
> while (ret != -1 && !done)
> ret = wl_display_dispatch_queue(dri2_dpy->wl_dpy, dri2_dpy->wl_queue);
If we're bumping the libwayland-client dep anyway, might as well just
make this use wl_display_roundtrip_queue.
> @@ -1235,6 +1237,10 @@ dri2_initialize_wayland_drm(_EGLDriver *drv, _EGLDisplay *disp)
> wl_drm_destroy(dri2_dpy->wl_drm);
> cleanup_registry:
> wl_registry_destroy(dri2_dpy->wl_registry);
> + wl_proxy_wrapper_destroy(dri2_dpy->wl_dpy_wrapper);
> + cleanup_dpy_wrapper:
> + if (dri2_dpy->wl_dpy != disp->PlatformDisplay)
> + wl_display_disconnect(dri2_dpy->wl_dpy);
> wl_event_queue_destroy(dri2_dpy->wl_queue);
> cleanup_dpy:
> free(dri2_dpy);
Adding wl_display_disconnect should be a separate change, and in any
case needs to come after wl_event_queue_destroy to avoid a
use-after-free.
With those fixed, assuming we're fine with an increased hard dep:
Reviewed-by: Daniel Stone <daniels at collabora.com>
Cheers,
Daniel
More information about the mesa-dev
mailing list