client: Introduce proxy wrappers
authorJonas Ådahl <jadahl@gmail.com>
Fri, 29 Apr 2016 11:30:22 +0000 (19:30 +0800)
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>
Fri, 29 Apr 2016 12:58:23 +0000 (15:58 +0300)
commit6d29c0da3cd168e08187cd204d2314188479c0f1
tree3466c77ec6da0f2fb24d16fa17d1e7da4e77a0e5
parent9a652c44f7fb9ce6894a41a87d8fe571ad59969d
client: Introduce proxy wrappers

Using the libwayland-client client API with multiple threads with
thread local queues are prone to race conditions.

The problem is that one thread can read and queue events after another
thread creates a proxy but before it sets the queue.

This may result in the event to the proxy being silently dropped, or
potentially dispatched on the wrong thread had the creating thread set
the implementation before setting the queue.

This patch introduces API to solve this case by introducing "proxy
wrappers". In short, a proxy wrapper is a wl_proxy struct that will
never itself proxy any events, but may be used by the client to set a
queue, and use it instead of the original proxy when sending requests
that creates new proxies. When sending requests, the wrapper will
work in the same way as the normal proxy object, but the proxy created
by sending a request (for example wl_display.sync) will inherit to the
same proxy queue as the wrapper.

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

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
src/wayland-client-core.h
src/wayland-client.c