client: Add new proxy marshalling functions with flags

There's a race when destroying wayland objects in a multi-threaded client.
This occurs because we call:
wl_proxy_marshal(foo);
wl_proxy_destroy(foo);

And each of these functions takes, and releases, the display mutex.
Between the two calls, the display is not locked.

In order to allow atomically marshalling the proxy and destroying the
proxy without releasing the lock, add yet more wl_proxy_marshal_*
functions.  This time add flags and jam in all existing warts with the
hope that we can make it future proof this time.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
Derek Foreman 2021-07-21 16:26:00 -05:00 committed by Daniel Stone
parent 942f1d8843
commit 23e4a70600
2 changed files with 105 additions and 2 deletions

View file

@ -119,9 +119,27 @@ struct wl_display;
*/
struct wl_event_queue;
/** Destroy proxy after marshalling
* @ingroup wl_proxy
*/
#define WL_MARSHAL_FLAG_DESTROY (1 << 0)
void
wl_event_queue_destroy(struct wl_event_queue *queue);
struct wl_proxy *
wl_proxy_marshal_flags(struct wl_proxy *proxy, uint32_t opcode,
const struct wl_interface *interface,
uint32_t version,
uint32_t flags, ...);
struct wl_proxy *
wl_proxy_marshal_array_flags(struct wl_proxy *proxy, uint32_t opcode,
const struct wl_interface *interface,
uint32_t version,
uint32_t flags,
union wl_argument *args);
void
wl_proxy_marshal(struct wl_proxy *p, uint32_t opcode, ...);