summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-04-09 11:52:55 +0200
committerThomas Haller <thaller@redhat.com>2018-04-13 09:09:46 +0200
commit50b74731f668067d445a28d7e545a169bf9d25c8 (patch)
tree5e1e829c5acbf76d8292e06f99008be530eb0421
parentbfaa291d89c02ee68780aa28eb7f19e1a925954f (diff)
auth-chain/trivial: rename nm_auth_chain_unref() to nm_auth_chain_destroy()
NMAuthChain is not really ref-counted. True, we have an internal ref-counter to ensure that the instance stays alive while the callback is invoked. However, the user cannot take additional references as there is no nm_auth_chain_ref(). When the user wants to get rid of the auth-chain, with the current API it is important that the callback won't be called after that point. From the name nm_auth_chain_unref(), it sounds like that there could be multiple references to the auth-chain, and merely unreferencing the object might not guarantee that the callback is canceled. However, that is luckily not the case, because there is no real ref-counting involved here. Just rename the destroy function to make this clearer.
-rw-r--r--src/nm-active-connection.c4
-rw-r--r--src/nm-auth-utils.c13
-rw-r--r--src/nm-auth-utils.h2
-rw-r--r--src/nm-manager.c20
-rw-r--r--src/settings/nm-agent-manager.c12
-rw-r--r--src/settings/nm-settings-connection.c4
-rw-r--r--src/settings/nm-settings.c6
7 files changed, 32 insertions, 29 deletions
diff --git a/src/nm-active-connection.c b/src/nm-active-connection.c
index e182e65df9..a02deb3b5b 100644
--- a/src/nm-active-connection.c
+++ b/src/nm-active-connection.c
@@ -1030,7 +1030,7 @@ auth_done (NMAuthChain *chain,
priv->result_func (self, TRUE, NULL, priv->user_data1, priv->user_data2);
done:
- nm_auth_chain_unref (chain);
+ nm_auth_chain_destroy (chain);
priv->chain = NULL;
priv->result_func = NULL;
priv->user_data1 = NULL;
@@ -1388,7 +1388,7 @@ dispose (GObject *object)
_LOGD ("disposing");
if (priv->chain) {
- nm_auth_chain_unref (priv->chain);
+ nm_auth_chain_destroy (priv->chain);
priv->chain = NULL;
}
diff --git a/src/nm-auth-utils.c b/src/nm-auth-utils.c
index 93aee45008..da5843b0bf 100644
--- a/src/nm-auth-utils.c
+++ b/src/nm-auth-utils.c
@@ -219,7 +219,7 @@ auth_chain_finish (gpointer user_data)
/* Ensure we stay alive across the callback */
self->refcount++;
self->done_func (self, NULL, self->context, self->user_data);
- nm_auth_chain_unref (self);
+ nm_auth_chain_destroy (self);
return FALSE;
}
@@ -394,17 +394,20 @@ nm_auth_chain_new_subject (NMAuthSubject *subject,
}
/**
- * nm_auth_chain_unref:
+ * nm_auth_chain_destroy:
* @self: the auth-chain
*
- * Unrefs the auth-chain. By unrefing the auth-chain, you also cancel
+ * Destroys the auth-chain. By destroying the auth-chain, you also cancel
* the receipt of the done-callback. IOW, the callback will not be invoked.
*
- * The only exception is, if you call nm_auth_chain_unref() from inside
+ * The only exception is, if may call nm_auth_chain_destroy() from inside
* the callback. In this case, @self stays alive until the callback returns.
+ *
+ * Note that you might only destroy an auth-chain exactly once, and never
+ * after the callback was handled.
*/
void
-nm_auth_chain_unref (NMAuthChain *self)
+nm_auth_chain_destroy (NMAuthChain *self)
{
AuthCall *call;
diff --git a/src/nm-auth-utils.h b/src/nm-auth-utils.h
index 335edb5b36..808da86a51 100644
--- a/src/nm-auth-utils.h
+++ b/src/nm-auth-utils.h
@@ -62,7 +62,7 @@ void nm_auth_chain_add_call (NMAuthChain *chain,
const char *permission,
gboolean allow_interaction);
-void nm_auth_chain_unref (NMAuthChain *chain);
+void nm_auth_chain_destroy (NMAuthChain *chain);
/* Caller must free returned error description */
gboolean nm_auth_is_subject_in_acl (NMConnection *connection,
diff --git a/src/nm-manager.c b/src/nm-manager.c
index ed1aace333..612f41562c 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -953,7 +953,7 @@ _reload_auth_cb (NMAuthChain *chain,
g_dbus_method_invocation_return_value (context, NULL);
out:
- nm_auth_chain_unref (chain);
+ nm_auth_chain_destroy (chain);
}
static void
@@ -2100,7 +2100,7 @@ device_auth_done_cb (NMAuthChain *chain,
nm_auth_chain_get_data (chain, "user-data"));
g_clear_error (&error);
- nm_auth_chain_unref (chain);
+ nm_auth_chain_destroy (chain);
}
static void
@@ -4796,7 +4796,7 @@ deactivate_net_auth_done_cb (NMAuthChain *chain,
else
g_dbus_method_invocation_return_value (context, NULL);
- nm_auth_chain_unref (chain);
+ nm_auth_chain_destroy (chain);
}
static void
@@ -5138,7 +5138,7 @@ sleep_auth_done_cb (NMAuthChain *chain,
g_dbus_method_invocation_return_value (context, NULL);
}
- nm_auth_chain_unref (chain);
+ nm_auth_chain_destroy (chain);
}
#endif
@@ -5276,7 +5276,7 @@ enable_net_done_cb (NMAuthChain *chain,
g_dbus_method_invocation_take_error (context, ret_error);
}
- nm_auth_chain_unref (chain);
+ nm_auth_chain_destroy (chain);
}
static void
@@ -5384,7 +5384,7 @@ get_permissions_done_cb (NMAuthChain *chain,
g_variant_new ("(a{ss})", &results));
}
- nm_auth_chain_unref (chain);
+ nm_auth_chain_destroy (chain);
}
static void
@@ -5606,7 +5606,7 @@ check_connectivity_auth_done_cb (NMAuthChain *chain,
}
out:
- nm_auth_chain_unref (chain);
+ nm_auth_chain_destroy (chain);
}
static void
@@ -6017,7 +6017,7 @@ out:
g_dbus_method_invocation_return_dbus_error (invocation, error_name, error_message);
else
g_dbus_method_invocation_return_value (invocation, NULL);
- nm_auth_chain_unref (chain);
+ nm_auth_chain_destroy (chain);
}
void
@@ -6152,7 +6152,7 @@ checkpoint_auth_done_cb (NMAuthChain *chain,
else
g_dbus_method_invocation_return_value (context, variant);
- nm_auth_chain_unref (chain);
+ nm_auth_chain_destroy (chain);
}
static void
@@ -6830,7 +6830,7 @@ dispose (GObject *object)
g_slice_free (PlatformLinkCbData, data);
}
- g_slist_free_full (priv->auth_chains, (GDestroyNotify) nm_auth_chain_unref);
+ g_slist_free_full (priv->auth_chains, (GDestroyNotify) nm_auth_chain_destroy);
priv->auth_chains = NULL;
nm_clear_g_source (&priv->devices_inited_id);
diff --git a/src/settings/nm-agent-manager.c b/src/settings/nm-agent-manager.c
index b2cdc7d922..00aa3a0865 100644
--- a/src/settings/nm-agent-manager.c
+++ b/src/settings/nm-agent-manager.c
@@ -360,7 +360,7 @@ agent_register_permissions_done (NMAuthChain *chain,
request_add_agent (c_list_entry (iter, Request, lst_request), agent);
}
- nm_auth_chain_unref (chain);
+ nm_auth_chain_destroy (chain);
}
static NMSecretAgent *
@@ -539,7 +539,7 @@ request_free (Request *req)
g_object_unref (req->con.connection);
g_free (req->con.path);
if (req->con.chain)
- nm_auth_chain_unref (req->con.chain);
+ nm_auth_chain_destroy (req->con.chain);
if (req->request_type == REQUEST_TYPE_CON_GET) {
g_free (req->con.get.setting_name);
g_strfreev (req->con.get.hints);
@@ -810,7 +810,7 @@ request_remove_agent (Request *req, NMSecretAgent *agent)
case REQUEST_TYPE_CON_DEL:
if (req->con.chain) {
/* This cancels the pending authorization requests. */
- nm_auth_chain_unref (req->con.chain);
+ nm_auth_chain_destroy (req->con.chain);
req->con.chain = NULL;
}
break;
@@ -1047,7 +1047,7 @@ _con_get_request_start_validated (NMAuthChain *chain,
_con_get_request_start_proceed (req, req->con.current_has_modify);
}
- nm_auth_chain_unref (chain);
+ nm_auth_chain_destroy (chain);
}
static void
@@ -1541,7 +1541,7 @@ agent_permissions_changed_done (NMAuthChain *chain,
nm_secret_agent_add_permission (agent, NM_AUTH_PERMISSION_WIFI_SHARE_PROTECTED, share_protected);
nm_secret_agent_add_permission (agent, NM_AUTH_PERMISSION_WIFI_SHARE_OPEN, share_open);
- nm_auth_chain_unref (chain);
+ nm_auth_chain_destroy (chain);
}
static void
@@ -1616,7 +1616,7 @@ cancel_more:
goto cancel_more;
}
- g_slist_free_full (priv->chains, (GDestroyNotify) nm_auth_chain_unref);
+ g_slist_free_full (priv->chains, (GDestroyNotify) nm_auth_chain_destroy);
priv->chains = NULL;
if (priv->agents) {
diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c
index 88f9c18085..e72a623e7b 100644
--- a/src/settings/nm-settings-connection.c
+++ b/src/settings/nm-settings-connection.c
@@ -1408,7 +1408,7 @@ pk_auth_cb (NMAuthChain *chain,
callback (self, context, subject, error, callback_data);
g_clear_error (&error);
- nm_auth_chain_unref (chain);
+ nm_auth_chain_destroy (chain);
}
/**
@@ -3024,7 +3024,7 @@ dispose (GObject *object)
g_clear_object (&priv->agent_secrets);
/* Cancel PolicyKit requests */
- g_slist_free_full (priv->pending_auths, (GDestroyNotify) nm_auth_chain_unref);
+ g_slist_free_full (priv->pending_auths, (GDestroyNotify) nm_auth_chain_destroy);
priv->pending_auths = NULL;
g_clear_pointer (&priv->seen_bssids, g_hash_table_destroy);
diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c
index 67e035f038..20346929d6 100644
--- a/src/settings/nm-settings.c
+++ b/src/settings/nm-settings.c
@@ -1205,7 +1205,7 @@ pk_add_cb (NMAuthChain *chain,
send_agent_owned_secrets (self, added, subject);
g_clear_error (&error);
- nm_auth_chain_unref (chain);
+ nm_auth_chain_destroy (chain);
}
/* FIXME: remove if/when kernel supports adhoc wpa */
@@ -1563,7 +1563,7 @@ pk_hostname_cb (NMAuthChain *chain,
else
g_dbus_method_invocation_return_value (context, NULL);
- nm_auth_chain_unref (chain);
+ nm_auth_chain_destroy (chain);
}
static void
@@ -1912,7 +1912,7 @@ dispose (GObject *object)
NMSettings *self = NM_SETTINGS (object);
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);
- g_slist_free_full (priv->auths, (GDestroyNotify) nm_auth_chain_unref);
+ g_slist_free_full (priv->auths, (GDestroyNotify) nm_auth_chain_destroy);
priv->auths = NULL;
g_object_unref (priv->agent_mgr);