Lines Matching refs:slot

21         _cleanup_free_ sd_netlink_slot *slot = NULL;  in netlink_slot_allocate()  local
26 slot = malloc0(offsetof(sd_netlink_slot, reply_callback) + extra); in netlink_slot_allocate()
27 if (!slot) in netlink_slot_allocate()
30 slot->n_ref = 1; in netlink_slot_allocate()
31 slot->netlink = nl; in netlink_slot_allocate()
32 slot->userdata = userdata; in netlink_slot_allocate()
33 slot->type = type; in netlink_slot_allocate()
34 slot->floating = floating; in netlink_slot_allocate()
37 slot->description = strdup(description); in netlink_slot_allocate()
38 if (!slot->description) in netlink_slot_allocate()
45 LIST_PREPEND(slots, nl->slots, slot); in netlink_slot_allocate()
47 *ret = TAKE_PTR(slot); in netlink_slot_allocate()
52 void netlink_slot_disconnect(sd_netlink_slot *slot, bool unref) { in netlink_slot_disconnect() argument
55 assert(slot); in netlink_slot_disconnect()
57 nl = slot->netlink; in netlink_slot_disconnect()
61 switch (slot->type) { in netlink_slot_disconnect()
64 (void) hashmap_remove(nl->reply_callbacks, &slot->reply_callback.serial); in netlink_slot_disconnect()
66 if (slot->reply_callback.timeout != 0) in netlink_slot_disconnect()
67 … prioq_remove(nl->reply_callbacks_prioq, &slot->reply_callback, &slot->reply_callback.prioq_idx); in netlink_slot_disconnect()
71 LIST_REMOVE(match_callbacks, nl->match_callbacks, &slot->match_callback); in netlink_slot_disconnect()
73 for (size_t i = 0; i < slot->match_callback.n_groups; i++) in netlink_slot_disconnect()
74 (void) socket_broadcast_group_unref(nl, slot->match_callback.groups[i]); in netlink_slot_disconnect()
76 slot->match_callback.n_groups = 0; in netlink_slot_disconnect()
77 slot->match_callback.groups = mfree(slot->match_callback.groups); in netlink_slot_disconnect()
84 slot->type = _NETLINK_SLOT_INVALID; in netlink_slot_disconnect()
85 slot->netlink = NULL; in netlink_slot_disconnect()
86 LIST_REMOVE(slots, nl->slots, slot); in netlink_slot_disconnect()
88 if (!slot->floating) in netlink_slot_disconnect()
91 sd_netlink_slot_unref(slot); in netlink_slot_disconnect()
94 static sd_netlink_slot* netlink_slot_free(sd_netlink_slot *slot) { in netlink_slot_free() argument
95 assert(slot); in netlink_slot_free()
97 netlink_slot_disconnect(slot, false); in netlink_slot_free()
99 if (slot->destroy_callback) in netlink_slot_free()
100 slot->destroy_callback(slot->userdata); in netlink_slot_free()
102 free(slot->description); in netlink_slot_free()
103 return mfree(slot); in netlink_slot_free()
108 sd_netlink *sd_netlink_slot_get_netlink(sd_netlink_slot *slot) { in sd_netlink_slot_get_netlink() argument
109 assert_return(slot, NULL); in sd_netlink_slot_get_netlink()
111 return slot->netlink; in sd_netlink_slot_get_netlink()
114 void *sd_netlink_slot_get_userdata(sd_netlink_slot *slot) { in sd_netlink_slot_get_userdata() argument
115 assert_return(slot, NULL); in sd_netlink_slot_get_userdata()
117 return slot->userdata; in sd_netlink_slot_get_userdata()
120 void *sd_netlink_slot_set_userdata(sd_netlink_slot *slot, void *userdata) { in sd_netlink_slot_set_userdata() argument
123 assert_return(slot, NULL); in sd_netlink_slot_set_userdata()
125 ret = slot->userdata; in sd_netlink_slot_set_userdata()
126 slot->userdata = userdata; in sd_netlink_slot_set_userdata()
131 int sd_netlink_slot_get_destroy_callback(sd_netlink_slot *slot, sd_netlink_destroy_t *callback) { in sd_netlink_slot_get_destroy_callback() argument
132 assert_return(slot, -EINVAL); in sd_netlink_slot_get_destroy_callback()
135 *callback = slot->destroy_callback; in sd_netlink_slot_get_destroy_callback()
137 return !!slot->destroy_callback; in sd_netlink_slot_get_destroy_callback()
140 int sd_netlink_slot_set_destroy_callback(sd_netlink_slot *slot, sd_netlink_destroy_t callback) { in sd_netlink_slot_set_destroy_callback() argument
141 assert_return(slot, -EINVAL); in sd_netlink_slot_set_destroy_callback()
143 slot->destroy_callback = callback; in sd_netlink_slot_set_destroy_callback()
147 int sd_netlink_slot_get_floating(sd_netlink_slot *slot) { in sd_netlink_slot_get_floating() argument
148 assert_return(slot, -EINVAL); in sd_netlink_slot_get_floating()
150 return slot->floating; in sd_netlink_slot_get_floating()
153 int sd_netlink_slot_set_floating(sd_netlink_slot *slot, int b) { in sd_netlink_slot_set_floating() argument
154 assert_return(slot, -EINVAL); in sd_netlink_slot_set_floating()
156 if (slot->floating == !!b) in sd_netlink_slot_set_floating()
159 if (!slot->netlink) /* Already disconnected */ in sd_netlink_slot_set_floating()
162 slot->floating = b; in sd_netlink_slot_set_floating()
165 sd_netlink_slot_ref(slot); in sd_netlink_slot_set_floating()
166 sd_netlink_unref(slot->netlink); in sd_netlink_slot_set_floating()
168 sd_netlink_ref(slot->netlink); in sd_netlink_slot_set_floating()
169 sd_netlink_slot_unref(slot); in sd_netlink_slot_set_floating()
175 int sd_netlink_slot_get_description(sd_netlink_slot *slot, const char **description) { in sd_netlink_slot_get_description() argument
176 assert_return(slot, -EINVAL); in sd_netlink_slot_get_description()
179 *description = slot->description; in sd_netlink_slot_get_description()
181 return !!slot->description; in sd_netlink_slot_get_description()
184 int sd_netlink_slot_set_description(sd_netlink_slot *slot, const char *description) { in sd_netlink_slot_set_description() argument
185 assert_return(slot, -EINVAL); in sd_netlink_slot_set_description()
187 return free_and_strdup(&slot->description, description); in sd_netlink_slot_set_description()