From: Christopher Faulet Date: Wed, 10 Mar 2021 13:40:39 +0000 (+0100) Subject: MINOR: resolvers: Use a function to remove answers attached to a resolution X-Git-Url: http://git.haproxy.org/?a=commitdiff_plain;h=9f6c180c4ee53996a3cda38a3b32b406cebf6b1e;p=haproxy-2.1.git MINOR: resolvers: Use a function to remove answers attached to a resolution resolv_purge_resolution_answer_records() must be used to removed all answers attached to a resolution. For now, it is only used when a resolution is released. (cherry picked from commit 1dec5c793474027ddffbfca3849e5ca4e9e51083) Signed-off-by: Christopher Faulet (cherry picked from commit 656b42714a05e578c0480f1751a065d8e96f8f3a) Signed-off-by: Christopher Faulet (cherry picked from commit 67cc9a6dc2d6cdf0686c36178440a6c4236ac5f3) [cf: Must be backported as far as 2.0 because of recent changes on resolvers] Signed-off-by: Christopher Faulet --- diff --git a/include/proto/dns.h b/include/proto/dns.h index 7ce5a09..19159d6 100644 --- a/include/proto/dns.h +++ b/include/proto/dns.h @@ -42,6 +42,7 @@ int dns_get_ip_from_response(struct dns_response_packet *dns_p, void **newip, short *newip_sin_family, void *owner); +void dns_purge_resolution_answer_records(struct dns_resolution *resolution); int dns_link_resolution(void *requester, int requester_type, int requester_locked); void dns_unlink_resolution(struct dns_requester *requester); void dns_trigger_resolution(struct dns_requester *requester); diff --git a/src/dns.c b/src/dns.c index a04e137..6ec246c 100644 --- a/src/dns.c +++ b/src/dns.c @@ -1350,11 +1350,20 @@ static struct dns_resolution *dns_pick_resolution(struct dns_resolvers *resolver return res; } +void dns_purge_resolution_answer_records(struct dns_resolution *resolution) +{ + struct dns_answer_item *item, *itemback; + + list_for_each_entry_safe(item, itemback, &resolution->response.answer_list, list) { + LIST_DEL(&item->list); + pool_free(dns_answer_item_pool, item); + } +} + /* Releases a resolution from its requester(s) and move it back to the pool */ static void dns_free_resolution(struct dns_resolution *resolution) { struct dns_requester *req, *reqback; - struct dns_answer_item *item, *itemback; /* clean up configuration */ dns_reset_resolution(resolution); @@ -1366,11 +1375,7 @@ static void dns_free_resolution(struct dns_resolution *resolution) req->resolution = NULL; } - list_for_each_entry_safe(item, itemback, &resolution->response.answer_list, list) { - LIST_DEL(&item->list); - pool_free(dns_answer_item_pool, item); - } - + dns_purge_resolution_answer_records(resolution); LIST_DEL(&resolution->list); pool_free(dns_resolution_pool, resolution); }