mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-04 13:29:51 -05:00
client: Refactor wl_proxy_destroy critical section
Split wl_proxy_destroy into two pieces, wl_proxy_destroy_unlocked which performs the critical section code with no locking, and wl_proxy_destroy which locks before calling that. We'll use the new unlocked variant later in code that already holds the lock. There is a slight functional change - an aborting check is now called with the lock held. This should be harmless as wl_abort() performs no locking. Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
parent
6ebe3cfed0
commit
942f1d8843
1 changed files with 17 additions and 4 deletions
|
|
@ -514,12 +514,26 @@ proxy_destroy(struct wl_proxy *proxy)
|
||||||
wl_proxy_unref(proxy);
|
wl_proxy_unref(proxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
wl_proxy_destroy_caller_locks(struct wl_proxy *proxy)
|
||||||
|
{
|
||||||
|
if (proxy->flags & WL_PROXY_FLAG_WRAPPER)
|
||||||
|
wl_abort("Tried to destroy wrapper with wl_proxy_destroy()\n");
|
||||||
|
|
||||||
|
proxy_destroy(proxy);
|
||||||
|
}
|
||||||
|
|
||||||
/** Destroy a proxy object
|
/** Destroy a proxy object
|
||||||
*
|
*
|
||||||
* \param proxy The proxy to be destroyed
|
* \param proxy The proxy to be destroyed
|
||||||
*
|
*
|
||||||
* \c proxy must not be a proxy wrapper.
|
* \c proxy must not be a proxy wrapper.
|
||||||
*
|
*
|
||||||
|
* \note This function will abort in response to egregious
|
||||||
|
* errors, and will do so with the display lock held. This means
|
||||||
|
* SIGABRT handlers must not perform any actions that would
|
||||||
|
* attempt to take that lock, or a deadlock would occur.
|
||||||
|
*
|
||||||
* \memberof wl_proxy
|
* \memberof wl_proxy
|
||||||
*/
|
*/
|
||||||
WL_EXPORT void
|
WL_EXPORT void
|
||||||
|
|
@ -527,11 +541,10 @@ wl_proxy_destroy(struct wl_proxy *proxy)
|
||||||
{
|
{
|
||||||
struct wl_display *display = proxy->display;
|
struct wl_display *display = proxy->display;
|
||||||
|
|
||||||
if (proxy->flags & WL_PROXY_FLAG_WRAPPER)
|
|
||||||
wl_abort("Tried to destroy wrapper with wl_proxy_destroy()\n");
|
|
||||||
|
|
||||||
pthread_mutex_lock(&display->mutex);
|
pthread_mutex_lock(&display->mutex);
|
||||||
proxy_destroy(proxy);
|
|
||||||
|
wl_proxy_destroy_caller_locks(proxy);
|
||||||
|
|
||||||
pthread_mutex_unlock(&display->mutex);
|
pthread_mutex_unlock(&display->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue