network/queue: free assigned userdata only when a new request is queued

This commit is contained in:
Yu Watanabe
2023-07-29 23:27:19 +09:00
parent ae85704760
commit d256945fd0
2 changed files with 6 additions and 3 deletions
+5 -2
View File
@@ -702,7 +702,7 @@ int link_request_stacked_netdev(Link *link, NetDev *netdev) {
link->stacked_netdevs_created = false;
r = link_queue_request_full(link, REQUEST_TYPE_NETDEV_STACKED,
netdev_ref(netdev), (mfree_func_t) netdev_unref,
netdev, (mfree_func_t) netdev_unref,
trivial_hash_func, trivial_compare_func,
stacked_netdev_process_request,
&link->create_stacked_netdev_messages,
@@ -710,9 +710,12 @@ int link_request_stacked_netdev(Link *link, NetDev *netdev) {
if (r < 0)
return log_link_error_errno(link, r, "Failed to request stacked netdev '%s': %m",
netdev->ifname);
if (r == 0)
return 0;
netdev_ref(netdev);
log_link_debug(link, "Requested stacked netdev '%s'", netdev->ifname);
return 0;
return 1;
}
static int independent_netdev_process_request(Request *req, Link *link, void *userdata) {
+1 -1
View File
@@ -134,7 +134,6 @@ static int request_new(
.link = link_ref(link), /* link may be NULL, but link_ref() handles it gracefully. */
.type = type,
.userdata = userdata,
.free_func = free_func,
.hash_func = hash_func,
.compare_func = compare_func,
.process = process,
@@ -153,6 +152,7 @@ static int request_new(
return r;
req->manager = manager;
req->free_func = free_func;
req->counter = counter;
if (req->counter)
(*req->counter)++;