mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-05 20:30:35 +01:00
agents: don't make method calls with a destroyed proxy
If the agent has dropped off the bus then its proxy may already be destroyed, so we'll get warnings when trying to make method calls using it. Track proxy destruction and warn if we try to use a destroyed proxy.
This commit is contained in:
parent
724b9c045b
commit
802d4cdad2
1 changed files with 19 additions and 1 deletions
|
|
@ -53,6 +53,7 @@ typedef struct {
|
|||
GSList *permissions;
|
||||
|
||||
DBusGProxy *proxy;
|
||||
guint proxy_destroy_id;
|
||||
|
||||
GHashTable *requests;
|
||||
} NMSecretAgentPrivate;
|
||||
|
|
@ -274,6 +275,7 @@ nm_secret_agent_get_secrets (NMSecretAgent *self,
|
|||
g_return_val_if_fail (setting_name != NULL, NULL);
|
||||
|
||||
priv = NM_SECRET_AGENT_GET_PRIVATE (self);
|
||||
g_return_val_if_fail (priv->proxy != NULL, NULL);
|
||||
|
||||
hash = nm_connection_to_hash (connection, NM_SETTING_HASH_FLAG_ALL);
|
||||
|
||||
|
|
@ -321,6 +323,7 @@ nm_secret_agent_cancel_secrets (NMSecretAgent *self, gconstpointer call)
|
|||
|
||||
g_return_if_fail (self != NULL);
|
||||
priv = NM_SECRET_AGENT_GET_PRIVATE (self);
|
||||
g_return_if_fail (priv->proxy != NULL);
|
||||
|
||||
r = g_hash_table_lookup (priv->requests, call);
|
||||
g_return_if_fail (r != NULL);
|
||||
|
|
@ -424,6 +427,18 @@ nm_secret_agent_delete_secrets (NMSecretAgent *self,
|
|||
callback_data);
|
||||
}
|
||||
|
||||
static void
|
||||
proxy_cleanup (NMSecretAgent *self)
|
||||
{
|
||||
NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self);
|
||||
|
||||
if (priv->proxy) {
|
||||
g_signal_handler_disconnect (priv->proxy, priv->proxy_destroy_id);
|
||||
priv->proxy_destroy_id = 0;
|
||||
g_clear_object (&priv->proxy);
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
NMSecretAgent *
|
||||
|
|
@ -465,6 +480,8 @@ nm_secret_agent_new (DBusGMethodInvocation *context,
|
|||
NM_DBUS_PATH_SECRET_AGENT,
|
||||
NM_DBUS_INTERFACE_SECRET_AGENT);
|
||||
g_assert (priv->proxy);
|
||||
priv->proxy_destroy_id = g_signal_connect_swapped (priv->proxy, "destroy",
|
||||
G_CALLBACK (proxy_cleanup), self);
|
||||
|
||||
g_free (username);
|
||||
return self;
|
||||
|
|
@ -496,7 +513,8 @@ dispose (GObject *object)
|
|||
g_slist_free (priv->permissions);
|
||||
|
||||
g_hash_table_destroy (priv->requests);
|
||||
g_object_unref (priv->proxy);
|
||||
|
||||
proxy_cleanup (NM_SECRET_AGENT (object));
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (nm_secret_agent_parent_class)->dispose (object);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue