Lines Matching refs:req
10 static Request *request_free(Request *req) { in request_free() argument
11 if (!req) in request_free()
16 if (req->manager) in request_free()
17 ordered_set_remove(req->manager->request_queue, req); in request_free()
19 if (req->free_func) in request_free()
20 req->free_func(req->userdata); in request_free()
22 if (req->counter) in request_free()
23 (*req->counter)--; in request_free()
25 link_unref(req->link); /* link may be NULL, but link_unref() can handle it gracefully. */ in request_free()
27 return mfree(req); in request_free()
33 void request_detach(Manager *manager, Request *req) { in request_detach() argument
36 if (!req) in request_detach()
39 req = ordered_set_remove(manager->request_queue, req); in request_detach()
40 if (!req) in request_detach()
43 req->manager = NULL; in request_detach()
44 request_unref(req); in request_detach()
47 static void request_hash_func(const Request *req, struct siphash *state) { in request_hash_func() argument
48 assert(req); in request_hash_func()
51 siphash24_compress_boolean(req->link, state); in request_hash_func()
52 if (req->link) in request_hash_func()
53 siphash24_compress(&req->link->ifindex, sizeof(req->link->ifindex), state); in request_hash_func()
55 siphash24_compress(&req->type, sizeof(req->type), state); in request_hash_func()
57 siphash24_compress(&req->hash_func, sizeof(req->hash_func), state); in request_hash_func()
58 siphash24_compress(&req->compare_func, sizeof(req->compare_func), state); in request_hash_func()
60 if (req->hash_func) in request_hash_func()
61 req->hash_func(req->userdata, state); in request_hash_func()
118 _cleanup_(request_unrefp) Request *req = NULL; in request_new()
125 req = new(Request, 1); in request_new()
126 if (!req) { in request_new()
132 *req = (Request) { in request_new()
144 existing = ordered_set_get(manager->request_queue, req); in request_new()
151 r = ordered_set_ensure_put(&manager->request_queue, &request_hash_ops, req); in request_new()
155 req->manager = manager; in request_new()
156 req->counter = counter; in request_new()
157 if (req->counter) in request_new()
158 (*req->counter)++; in request_new()
161 *ret = req; in request_new()
163 TAKE_PTR(req); in request_new()
205 Request *req; in manager_process_requests() local
207 ORDERED_SET_FOREACH(req, manager->request_queue) { in manager_process_requests()
208 _unused_ _cleanup_(request_unrefp) Request *ref = request_ref(req); in manager_process_requests()
209 _cleanup_(link_unrefp) Link *link = link_ref(req->link); in manager_process_requests()
211 assert(req->process); in manager_process_requests()
213 r = req->process(req, link, req->userdata); in manager_process_requests()
218 request_detach(manager, req); in manager_process_requests()
236 static int request_netlink_handler(sd_netlink *nl, sd_netlink_message *m, Request *req) { in request_netlink_handler() argument
237 assert(req); in request_netlink_handler()
239 if (req->counter) { in request_netlink_handler()
240 assert(*req->counter > 0); in request_netlink_handler()
241 (*req->counter)--; in request_netlink_handler()
242 req->counter = NULL; /* To prevent double decrement on free. */ in request_netlink_handler()
245 if (req->link && IN_SET(req->link->state, LINK_STATE_FAILED, LINK_STATE_LINGER)) in request_netlink_handler()
248 if (req->netlink_handler) in request_netlink_handler()
249 return req->netlink_handler(nl, m, req, req->link, req->userdata); in request_netlink_handler()
254 int request_call_netlink_async(sd_netlink *nl, sd_netlink_message *m, Request *req) { in request_call_netlink_async() argument
259 assert(req); in request_call_netlink_async()
261 r = netlink_call_async(nl, NULL, m, request_netlink_handler, request_destroy_callback, req); in request_call_netlink_async()
265 request_ref(req); in request_call_netlink_async()