summaryrefslogtreecommitdiff
path: root/src/nm-auth-utils.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-05-26 18:49:55 +0200
committerThomas Haller <thaller@redhat.com>2019-06-13 16:10:53 +0200
commit142c1215ee1b8423e7739175a0382a91924629c6 (patch)
treec708cd970f62657a879546821b7ab1fb10b94aef /src/nm-auth-utils.c
parenta63714ec1de4ad174f04569726a23de7928d96cb (diff)
downloadNetworkManager-142c1215ee1b8423e7739175a0382a91924629c6.tar.gz
auth-chain: track auth-chains in embedded CList
NMManager and NMSettings both may have multiple authorization requests ongoing. They need to keep track of them, at the very least to be able to cancel them on shutdown. Since NMAuthChain is not ref-countable, it always has only one clear user/owner. It makes little sense otherwise. Since most callers already want to track their NMAuthChain instances, let NMAuthChain help with that. Embed a "parent" CList field inside NMAuthChain. This avoids requiring an additional GSList allocation to track the element. Also, it allows to link and append an element without iterating the list. This ties the caller and the NMAuthChain a bit tighter together (making them less indepdendent). Generally that is not desirable. But here it seems the logic (of tracking the NMAuthChain) is still trivial and well separated. It's just that NMAuthChain instances now can be linked in a CList.
Diffstat (limited to 'src/nm-auth-utils.c')
-rw-r--r--src/nm-auth-utils.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/nm-auth-utils.c b/src/nm-auth-utils.c
index ab7c1887dd..7235cba1a8 100644
--- a/src/nm-auth-utils.c
+++ b/src/nm-auth-utils.c
@@ -30,6 +30,9 @@
/*****************************************************************************/
struct NMAuthChain {
+
+ CList parent_lst;
+
CList data_lst_head;
CList auth_call_lst_head;
@@ -46,6 +49,8 @@ struct NMAuthChain {
bool is_finishing:1;
};
+G_STATIC_ASSERT (G_STRUCT_OFFSET (NMAuthChain, parent_lst) == 0);
+
typedef struct {
CList auth_call_lst;
NMAuthChain *chain;
@@ -435,6 +440,7 @@ nm_auth_chain_new_subject (NMAuthSubject *subject,
.user_data = user_data,
.context = nm_g_object_ref (context),
.subject = g_object_ref (subject),
+ .parent_lst = C_LIST_INIT (self->parent_lst),
.data_lst_head = C_LIST_INIT (self->data_lst_head),
.auth_call_lst_head = C_LIST_INIT (self->auth_call_lst_head),
};
@@ -479,6 +485,8 @@ _auth_chain_destroy (NMAuthChain *self)
AuthCall *call;
ChainData *chain_data;
+ c_list_unlink (&self->parent_lst);
+
nm_clear_g_object (&self->subject);
nm_clear_g_object (&self->context);