[vlc-commits] Wayland: fix race when setting the queue

Rémi Denis-Courmont git at videolan.org
Mon Oct 28 05:25:53 CET 2019


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Oct 28 06:23:30 2019 +0200| [156ca3965ea3311826bebc77e400c77e165336e5] | committer: Rémi Denis-Courmont

Wayland: fix race when setting the queue

The queue cannot be set on live object that receives events.
See wl_proxy_create_wrapper() documentation for details.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=156ca3965ea3311826bebc77e400c77e165336e5
---

 modules/video_output/wayland/registry.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/modules/video_output/wayland/registry.c b/modules/video_output/wayland/registry.c
index 02be60d717..77fc83dee5 100644
--- a/modules/video_output/wayland/registry.c
+++ b/modules/video_output/wayland/registry.c
@@ -227,18 +227,20 @@ struct vlc_wl_registry *vlc_wl_registry_get(struct wl_display *display,
     if (unlikely(vr == NULL))
         return NULL;
 
-    vr->registry = wl_display_get_registry(display);
+    struct wl_display *wrapper = wl_proxy_create_wrapper(display);
+    if (unlikely(wrapper == NULL))
+        goto error;
+
+    wl_proxy_set_queue((struct wl_proxy *)wrapper, queue);
+    vr->registry = wl_display_get_registry(wrapper);
+    wl_proxy_wrapper_destroy(wrapper);
+
     if (unlikely(vr->registry == NULL))
-    {
-        free(vr);
-        return NULL;
-    }
+        goto error;
 
     vr->interfaces = NULL;
     vr->names = NULL;
 
-    /* FIXME: setting queue is not thread safe */
-    wl_proxy_set_queue((struct wl_proxy *)vr->registry, queue);
     wl_registry_add_listener(vr->registry, &registry_cbs, vr);
 
      /* complete registry enumeration */
@@ -248,6 +250,9 @@ struct vlc_wl_registry *vlc_wl_registry_get(struct wl_display *display,
         vr = NULL;
     }
 
+    return vr;
+error:
+    free(vr);
     return vr;
 }
 



More information about the vlc-commits mailing list