[Wayland-bugs] [Bug 763852] gdk/wayland: event source is not multi-thread aware
gtk+ (GNOME Bugzilla)
bugzilla at gnome.org
Fri Apr 1 01:18:17 UTC 2016
https://bugzilla.gnome.org/show_bug.cgi?id=763852
Matthew Waters (ystreet00) <ystreet00 at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #324334|needs-work |none
status| |
Attachment #324334|0 |1
is obsolete| |
--- Comment #10 from Matthew Waters (ystreet00) <ystreet00 at gmail.com> ---
Created attachment 325118
--> https://bugzilla.gnome.org/attachment.cgi?id=325118&action=edit
gdk/wayland: use the multi-thread safe wayland dispatching API
(In reply to Jonas Ã…dahl from comment #9)
> Review of attachment 324334 [details] [review]:
> ::: gdk/wayland/gdkeventsource.c
> @@ +58,3 @@
> + * wl_display_cancel_read() */
> + if (source->reading)
> + wl_display_cancel_read (display->wl_display);
>
> When will this actually happen? Anyway, if it is needed, we should cancel
> the read the first thing in this function, so that we don't leave this
> function without later polling the fd.
It used to happen in earlier patch versions. I've replaced it with an assert
instead.
> @@ +60,3 @@
> + wl_display_cancel_read (display->wl_display);
> +
> + while (wl_display_prepare_read (display->wl_display) != 0)
>
> I think we can just do if (wl_display_prepare_read (display->wl_display) !=
> 0) return TRUE; as it means we can already dispatch without polling.
>
> We also need to wl_display_prepare_read() on the potential return FALSE;
> path above (the first if statement in this function), so that we always have
> prepared for reading when we return FALSE.
As in when one of the previous conditions returns FALSE? I took a different
approach by only reading in check() when source->reading is TRUE.
Also, I wasn't sure if the revents & IN condition before dispatch_pending()
would always succeed when preemptively returning TRUE from prepare_read() so I
removed that as well so we always dispatch regardless of revents state. I
think that's still safe with the other gdk conditions possibly returning TRUE
from prepare().
> @@ +81,1 @@
> + if (source->display->event_pause_count > 0) {
>
> nit: { sholud go on its own line.
Fixed
> @@ +90,3 @@
> + {
> + if (wl_display_read_events (display_wayland->wl_display) < 0)
> + g_error ("Error reading events from display: %s", g_strerror
> (errno));
>
> I think it might be a good idea to either g_assert (source->reading) or
> g_return_if_fail (source->reading) before actually reading here.
That fails as prepare can return FALSE without reading (as you pointed out
above). I took the opposite approach of only reading when source->reading is
TRUE as that's simpler and involves less state tracking.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/wayland-bugs/attachments/20160401/618f4385/attachment-0001.html>
More information about the wayland-bugs
mailing list