[Wayland-bugs] [Bug 91273] It's not safe to share wl_display fd with other threads.
bugzilla-daemon at freedesktop.org
bugzilla-daemon at freedesktop.org
Mon Jul 20 21:26:34 PDT 2015
https://bugs.freedesktop.org/show_bug.cgi?id=91273
--- Comment #9 from Kristian Høgsberg <krh at bitplanet.net> ---
(In reply to Boram from comment #7)
> > I still don't understand what you mean by "the kernel may not wake up the
> > thread" if it refers to a different issue than the two mentioned above.
>
> When A thread is polling on a display fd and B thread is polling on the same
> display fd, if a server sends messages, sometimes only one thread(Let's say
> it is B thread) awakes and reads all events so fast. Then A thread still is
> in the polling status and can't awake. Even if B thread reads and queue all
> events into corresponding queue_lists, the events of A thread's queue_list
> can't be handled because A thread is still in sleep.
All threads call wl_display_read_events() after returning from poll(), but only
the last thread reads the data from the fd. That way we make sure all threads
who called wl_display_prepare_read_queue() will come out of poll before we read
the data.
The kernel may only wake one thread, but that's only an optimization. If that
thread doesn't read the data but goes to sleep on a pthread condition (the case
for the n-1 first threads), the other threads that block on poll will
eventually run and rendezvous in wl_display_read_events().
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-bugs/attachments/20150721/c37ef541/attachment.html>
More information about the wayland-bugs
mailing list