Skip to content
Snippets Groups Projects
Commit ded2e34e authored by George Kiagiadakis's avatar George Kiagiadakis
Browse files

global: properly destroy impl proxies that were removed by the server

When a pw_global is removed on the server (by pw_registry_destroy() or other
means), it triggers the proxy removed & the registry global_remove callbacks,
but it does not necessarily destroy the pw_proxy.

For client proxies, we were previously destroying them by unrefing the WpProxy
in wp_global_rm_flags(), since the global was not "owned" by the WpProxy.

For impl proxies, we were not doing anything, as we expected that it would
only be removed from the registry if the local WpProxy was destroyed first.
This is not always the case, though, as the server or another client may
request to destroy this proxy with pw_registry_destroy()

Now we always destroy the pw_proxy as soon as it is removed from the registry,
no matter if it was a client or an impl proxy. If it was an impl proxy,
the WpProxy will continue to live and it's up to the code that created it
to handle the "pw-proxy-destroyed" signal and do something meaningful.
If it was a client proxy, the global will still unref the WpProxy right after
destroying the pw_proxy and there is no change in behavior.
parent 3b086167
No related branches found
No related tags found
No related merge requests found
......@@ -1366,20 +1366,25 @@ wp_global_rm_flag (WpGlobal *global, guint rm_flag)
notify all listeners that the proxy is gone */
if (rm_flag == WP_GLOBAL_FLAG_OWNED_BY_PROXY) {
global->flags &= ~WP_GLOBAL_FLAG_OWNED_BY_PROXY;
if (reg)
if (reg && global->proxy) {
wp_registry_notify_rm_object (reg, global->proxy);
}
global->proxy = NULL;
}
/* registry removed the global */
else if (rm_flag == WP_GLOBAL_FLAG_APPEARS_ON_REGISTRY) {
global->flags &= ~WP_GLOBAL_FLAG_APPEARS_ON_REGISTRY;
/* if there is a proxy and it's not owning the global, destroy it */
if (global->flags == 0 && global->proxy) {
/* destroy the proxy if it exists */
if (global->proxy) {
if (reg)
wp_registry_notify_rm_object (reg, global->proxy);
wp_proxy_destroy (global->proxy);
g_clear_object (&global->proxy);
/* if the proxy is not owning the global, unref it */
if (global->flags == 0)
g_object_unref (global->proxy);
global->proxy = NULL;
}
}
......
......@@ -140,10 +140,17 @@ proxy_event_bound (void *data, uint32_t global_id)
g_signal_emit (self, wp_proxy_signals[SIGNAL_BOUND], 0, global_id);
}
static void
proxy_event_removed (void *data)
{
wp_trace_object (data, "removed");
}
static const struct pw_proxy_events proxy_events = {
PW_VERSION_PROXY_EVENTS,
.destroy = proxy_event_destroy,
.bound = proxy_event_bound,
.removed = proxy_event_removed,
};
void
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment