client: Fix wl_display_roundtrip_queue() race condition
authorJonas Ådahl <jadahl@gmail.com>
Wed, 27 Apr 2016 07:37:41 +0000 (15:37 +0800)
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>
Fri, 29 Apr 2016 13:03:33 +0000 (16:03 +0300)
commit6fe12f02e3b4879cd3d5faa08f023cc761d13be9
tree4949d62a7963acebea37017a4a7397aa2197ac8d
parent69ec70fb0d3f75f4bcce449238d6297f6a986b5f
client: Fix wl_display_roundtrip_queue() race condition

Without this commit, wl_display_roundtrip_queue() is vulnerable to a
race condition, causing the callback to be dispatched on the wrong
queue.

The race condition happens if some non-main thread calls
wl_display_roundtrip_queue() with its thread local queue, and the main
thread reads and dispatches the callback event from the
wl_display_sync() call before the thread local queue is set.

The issue is fixed by using a proxy wrapper, making the initialization
of the callback proxy atomic, effectively making it no longer possible
for some other thread to dispatch the proxy before the correct thread
local queue is set.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
[Pekka: check display_wrapper]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
src/wayland-client.c