modules: unregister the endpoints when their proxy is destroyed

This commit is contained in:
Julian Bouzas
2019-06-18 10:10:20 -04:00
parent 922065f97d
commit 42bdf3ee6d
2 changed files with 28 additions and 0 deletions

View File

@@ -76,6 +76,16 @@ proxy_info_destroy(gpointer p)
g_slice_free (struct proxy_info, p);
}
static void
unregister_endpoint (WpProxy* wp_proxy, WpEndpoint *endpoint)
{
g_return_if_fail(WP_IS_PROXY(wp_proxy));
g_return_if_fail(WP_IS_ENDPOINT(endpoint));
/* Unregister the endpoint */
wp_endpoint_unregister(endpoint);
}
static void
proxy_node_created(GObject *initable, GAsyncResult *res, gpointer d)
{
@@ -123,6 +133,10 @@ proxy_node_created(GObject *initable, GAsyncResult *res, gpointer d)
/* Register the endpoint */
wp_endpoint_register (endpoint);
/* Set destroy handler to unregister endpoint when the proxy is detroyed */
g_signal_connect (proxy_node, "destroyed", G_CALLBACK(unregister_endpoint),
endpoint);
/* Clean up */
proxy_info_destroy (pi);
}

View File

@@ -70,6 +70,16 @@ proxy_info_destroy(gpointer p)
g_slice_free (struct proxy_info, p);
}
static void
unregister_endpoint (WpProxy* wp_proxy, WpEndpoint *endpoint)
{
g_return_if_fail(WP_IS_PROXY(wp_proxy));
g_return_if_fail(WP_IS_ENDPOINT(endpoint));
/* Unregister the endpoint */
wp_endpoint_unregister(endpoint);
}
static void
proxy_node_created(GObject *initable, GAsyncResult *res, gpointer data)
{
@@ -114,6 +124,10 @@ proxy_node_created(GObject *initable, GAsyncResult *res, gpointer data)
/* Register the endpoint */
wp_endpoint_register (endpoint);
/* Set destroy handler to unregister endpoint when the proxy is detroyed */
g_signal_connect (proxy_node, "destroyed", G_CALLBACK(unregister_endpoint),
endpoint);
/* Clean up */
proxy_info_destroy (pi);
}