mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-04-10 03:02:28 +00:00
BUG/MEDIUM: dns: Release answer items when a DNS resolution is freed
When a DNS resolution is freed, the remaining items in .ar_list and .answer_list are also released. It must be done to avoid a memory leak. And it is the last chance to release these objects. I've honestly no idea if there is a better place to release them earlier. But at least, there is no more leak. This patch should solve the issue #222. It must be backported, at least, as far as 2.0, and probably, with caution, as far as 1.8 or 1.7.
This commit is contained in:
parent
5098a08c2f
commit
010ab35a91
11
src/dns.c
11
src/dns.c
@ -1573,6 +1573,7 @@ static struct dns_resolution *dns_pick_resolution(struct dns_resolvers *resolver
|
||||
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);
|
||||
@ -1584,6 +1585,16 @@ static void dns_free_resolution(struct dns_resolution *resolution)
|
||||
req->resolution = NULL;
|
||||
}
|
||||
|
||||
list_for_each_entry_safe(item, itemback, &resolution->response.ar_list, list) {
|
||||
LIST_DEL(&item->list);
|
||||
pool_free(dns_answer_item_pool, item);
|
||||
}
|
||||
|
||||
list_for_each_entry_safe(item, itemback, &resolution->response.answer_list, list) {
|
||||
LIST_DEL(&item->list);
|
||||
pool_free(dns_answer_item_pool, item);
|
||||
}
|
||||
|
||||
LIST_DEL(&resolution->list);
|
||||
pool_free(dns_resolution_pool, resolution);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user