aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel Stone <daniels@collabora.com>2017-12-28 15:41:18 +0000
committerDaniel Stone <daniels@collabora.com>2018-01-09 15:17:58 +0000
commitb39d8933973394432bf994b0c6e564fdaceb4757 (patch)
treea17836cf77829da6fcf9cd7fff6dcffa947fb1bd /src
parentclient: Remove WL_ZOMBIE_OBJECT global (diff)
downloadwayland-b39d8933973394432bf994b0c6e564fdaceb4757.tar
wayland-b39d8933973394432bf994b0c6e564fdaceb4757.tar.gz
wayland-b39d8933973394432bf994b0c6e564fdaceb4757.tar.bz2
wayland-b39d8933973394432bf994b0c6e564fdaceb4757.tar.lz
wayland-b39d8933973394432bf994b0c6e564fdaceb4757.tar.xz
wayland-b39d8933973394432bf994b0c6e564fdaceb4757.tar.zst
wayland-b39d8933973394432bf994b0c6e564fdaceb4757.zip
client: Use refcount exclusively for destruction
Commit e273c7cde added a refcount to wl_proxy. The refcount is set to 1 on creation, decreased when the client explicitly destroys the proxy, and is increased and decreased every time an event referencing that proxy is queued. Assuming no bugs, this means the refcount cannot reach 0 without the proxy being explicitly destroyed. However, some (not all) of the proxy-unref paths were only destroying the proxy if it had already been deleted. This should already be enforced by refcounting, so remove the check and rely solely on the refcount as the arbiter of when to free a proxy. Signed-off-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Derek Foreman <derekf@osg.samsung.com> Cc: Jonas Ã…dahl <jadahl@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/wayland-client.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/wayland-client.c b/src/wayland-client.c
index 21ef5b0..55838cd 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -258,7 +258,6 @@ wl_event_queue_release(struct wl_event_queue *queue)
{
struct wl_closure *closure;
struct wl_proxy *proxy;
- bool proxy_destroyed;
while (!wl_list_empty(&queue->event_list)) {
closure = container_of(queue->event_list.next,
@@ -268,10 +267,8 @@ wl_event_queue_release(struct wl_event_queue *queue)
decrease_closure_args_refcount(closure);
proxy = closure->proxy;
- proxy_destroyed = !!(proxy->flags & WL_PROXY_FLAG_DESTROYED);
-
proxy->refcount--;
- if (proxy_destroyed && !proxy->refcount)
+ if (!proxy->refcount)
free(proxy);
wl_closure_destroy(closure);
@@ -1310,10 +1307,10 @@ dispatch_event(struct wl_display *display, struct wl_event_queue *queue)
proxy_destroyed = !!(proxy->flags & WL_PROXY_FLAG_DESTROYED);
proxy->refcount--;
- if (proxy_destroyed) {
- if (!proxy->refcount)
- free(proxy);
+ if (!proxy->refcount)
+ free(proxy);
+ if (proxy_destroyed) {
wl_closure_destroy(closure);
return;
}