BUG/MEDIUM: resolvers: Don't defer resolutions release in deinit function

resolvers_deinit() function is called on error, during post-parsing stage,
or on deinit, when HAProxy is stopped. It releases all entities: resolvers,
resolutions and SRV requests. There is no reason to defer the resolutions
release by moving them in the death_row list because this function is
terminal. And it is in fact a bug. Resolutions must not be released at the
end of the function because resolvers were already freed. However some
resolutions may still be attached to a reolver. Thus, when we try to remove
it from the resolver's tree, in resolv_reset_resolution(), this resolver was
already released.

So now, resolution are immediately released. It means there is no more
reason to track this function. calls to
enter_resolver_code()/leave_resolver_code() have been removed.

This patch should fix the issue #1680 and may be related to #1485. It must
be backported as far as 2.2.
This commit is contained in:
Christopher Faulet 2022-05-24 18:10:42 +02:00
parent 1ba30167a0
commit 4315d17d3f

View File

@ -2412,7 +2412,6 @@ static void resolvers_deinit(void)
struct resolv_requester *req, *reqback; struct resolv_requester *req, *reqback;
struct resolv_srvrq *srvrq, *srvrqback; struct resolv_srvrq *srvrq, *srvrqback;
enter_resolver_code();
list_for_each_entry_safe(resolvers, resolversback, &sec_resolvers, list) { list_for_each_entry_safe(resolvers, resolversback, &sec_resolvers, list) {
list_for_each_entry_safe(ns, nsback, &resolvers->nameservers, list) { list_for_each_entry_safe(ns, nsback, &resolvers->nameservers, list) {
free(ns->id); free(ns->id);
@ -2445,7 +2444,7 @@ static void resolvers_deinit(void)
LIST_DEL_INIT(&req->list); LIST_DEL_INIT(&req->list);
pool_free(resolv_requester_pool, req); pool_free(resolv_requester_pool, req);
} }
abort_resolution(res); resolv_free_resolution(res);
} }
list_for_each_entry_safe(res, resback, &resolvers->resolutions.wait, list) { list_for_each_entry_safe(res, resback, &resolvers->resolutions.wait, list) {
@ -2453,7 +2452,7 @@ static void resolvers_deinit(void)
LIST_DEL_INIT(&req->list); LIST_DEL_INIT(&req->list);
pool_free(resolv_requester_pool, req); pool_free(resolv_requester_pool, req);
} }
abort_resolution(res); resolv_free_resolution(res);
} }
free_proxy(resolvers->px); free_proxy(resolvers->px);
@ -2470,8 +2469,6 @@ static void resolvers_deinit(void)
LIST_DEL_INIT(&srvrq->list); LIST_DEL_INIT(&srvrq->list);
free(srvrq); free(srvrq);
} }
leave_resolver_code();
} }
/* Finalizes the DNS configuration by allocating required resources and checking /* Finalizes the DNS configuration by allocating required resources and checking