[PATCH wayland] wayland-client : Fix duplicated proxy destroy
Jonas Ã…dahl
jadahl at gmail.com
Fri Jul 31 00:50:05 PDT 2015
On Fri, Jul 31, 2015 at 04:04:14PM +0900, Elvis Lee wrote:
> proxy_destroy can be called twice by wl_proxy_destroy and wl_event_queue_release.
> In that case, wl_map_remove should be called only once for same object id.
>
> Signed-off-by: Elvis Lee <kwangwoong.lee at lge.com>
Yepp. In 5c70c031 we started to destroy proxies when they were lingering
in a queue that was being released. But if such a proxy had been both
explicitly destroyed (with wl_proxy_destroy) and deleted via the
delete_id event but not be dispatched by the queue we'd now remove it
from the map twice.
However, I think we should rather do the same as when dispatching when
releasing from the queue, i.e:
1. check whether the proxy had been destroyed (proxy->flags &
WL_PROXY_FLAG_DESTROYED)
2. decrease the reference count, and free if we are the last holder.
Calling "destroy_proxy" in queue_release I believe is incorrect; the
original idea with WL_PROXY_FLAG_DESTROYED was that it had been
destroyed via wl_proxy_destroy.
Jonas
> ---
> src/wayland-client.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/src/wayland-client.c b/src/wayland-client.c
> index 6450b67..b087ed3 100644
> --- a/src/wayland-client.c
> +++ b/src/wayland-client.c
> @@ -405,6 +405,9 @@ wl_proxy_create_for_id(struct wl_proxy *factory,
> void
> proxy_destroy(struct wl_proxy *proxy)
> {
> + if (proxy->flags & WL_PROXY_FLAG_DESTROYED)
> + goto unreference;
> +
> if (proxy->flags & WL_PROXY_FLAG_ID_DELETED)
> wl_map_remove(&proxy->display->objects, proxy->object.id);
> else if (proxy->object.id < WL_SERVER_ID_START)
> @@ -417,6 +420,7 @@ proxy_destroy(struct wl_proxy *proxy)
>
> proxy->flags |= WL_PROXY_FLAG_DESTROYED;
>
> +unreference:
> proxy->refcount--;
> if (!proxy->refcount)
> free(proxy);
> --
> 1.7.9.5
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
More information about the wayland-devel
mailing list