From 6d29c0da3cd168e08187cd204d2314188479c0f1 Mon Sep 17 00:00:00 2001 From: Jonas Ådahl Date: Fri, 29 Apr 2016 19:30:22 +0800 Subject: client: Introduce proxy wrappers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Pekka Paalanen Reviewed-by: Derek Foreman --- src/wayland-client-core.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/wayland-client-core.h') diff --git a/src/wayland-client-core.h b/src/wayland-client-core.h index 91f7e7b..b1d6515 100644 --- a/src/wayland-client-core.h +++ b/src/wayland-client-core.h @@ -132,6 +132,12 @@ struct wl_proxy * wl_proxy_create(struct wl_proxy *factory, const struct wl_interface *interface); +void * +wl_proxy_create_wrapper(void *proxy); + +void +wl_proxy_wrapper_destroy(void *proxy_wrapper); + struct wl_proxy * wl_proxy_marshal_constructor(struct wl_proxy *proxy, uint32_t opcode, -- cgit v1.2.3-70-g09d2