https://bugs.freedesktop.org/show_bug.cgi?id=83304

--- Comment #2 from Pekka Paalanen <[email protected]> ---
Yeah, I don't think wl_display_roundtrip() is thread-safe.

It's really the same thing that dispatching the same queue from multiple
threads is a bad idea.

You should really have a queue dedicated to each thread, and dispatch that
queue only from that exact thread, never from any other thread. Otherwise your
event handlers become quite a bit complex and hard to make reliable. It might
even be impossible to implement correct locking for your own data structures
without a dedicated queue. You always want to know in which thread your
callbacks will run, and creating a new queue and using it consistently is the
tool to achieve that.

Unless you are running in the thread that dispatches the default queue (the
queue built in to wl_display), do not use wl_display_roundtrip(). Instead, use
wl_display_roundtrip_queue() which is new in 1.6, or open-code that if you need
to work with older libwayland-client.

Also, I think the docs on wl_display_dispatch_queue are outdated a bit:

 * This function blocks if there are no events to dispatch. If calling from
 * the main thread, it will block reading data from the display fd. For other
 * threads this will block until the main thread queues events on the queue
 * passed as argument.

Nowdays, any thread can read the fd, but it all works, if all threads follow
the polling protocol documented for wl_display_prepare_read().

I'm leaving this bug open, so that we would remember to check the
documentation.

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Wayland-bugs mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/wayland-bugs

Reply via email to