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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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,
|
||||
|
@@ -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);
|
||||
|
@@ -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) {
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user