proxy: don't remove the hooks, but report them leaking

When a client forgets to remove a hook, report them leaked in
the debug log. This is not a problem because we don't usually
add our own removed hook for proxies.

The problem is that we can't forcibly remove them with _clean()
from _destroy() because the hooks might be emitting the removed event
or the object listener. We could try to remove them in the final
unref but it seems some apps free their data before that and then
we unref invalid memory.
This commit is contained in:
Wim Taymans 2022-02-09 12:15:03 +01:00
parent 5fd427b86a
commit 50c5485efc

View file

@ -256,9 +256,6 @@ void pw_proxy_destroy(struct pw_proxy *proxy)
pw_proxy_emit_destroy(proxy); pw_proxy_emit_destroy(proxy);
} }
spa_hook_list_clean(&proxy->listener_list);
spa_hook_list_clean(&proxy->object_listener_list);
pw_proxy_unref(proxy); pw_proxy_unref(proxy);
} }
@ -291,6 +288,8 @@ void pw_proxy_remove(struct pw_proxy *proxy)
SPA_EXPORT SPA_EXPORT
void pw_proxy_unref(struct pw_proxy *proxy) void pw_proxy_unref(struct pw_proxy *proxy)
{ {
struct spa_hook *h;
assert(proxy->refcount > 0); assert(proxy->refcount > 0);
if (--proxy->refcount > 0) if (--proxy->refcount > 0)
return; return;
@ -298,6 +297,12 @@ void pw_proxy_unref(struct pw_proxy *proxy)
pw_log_debug("%p: free %u", proxy, proxy->id); pw_log_debug("%p: free %u", proxy, proxy->id);
/** client must explicitly destroy all proxies */ /** client must explicitly destroy all proxies */
assert(proxy->destroyed); assert(proxy->destroyed);
spa_list_for_each(h, &proxy->object_listener_list.list, link)
pw_log_debug("%p: leaked proxy object listener %p id:%d", proxy, h, proxy->id);
spa_list_for_each(h, &proxy->listener_list.list, link)
pw_log_debug("%p: leaked proxy listener %p id:%d", proxy, h, proxy->id);
free(proxy); free(proxy);
} }