CLEANUP: resolvers: simplify resolv_link_resolution() regarding requesters
authorWilly Tarreau <w@1wt.eu>
Tue, 19 Oct 2021 09:59:25 +0000 (11:59 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 3 Nov 2021 11:07:15 +0000 (12:07 +0100)
commit7e1e984a17dde4e82a22a1d33b513e2982d9e34f
tree246486d978eed7ee731b0e489e73a1a9900cddfd
parent10fec734c9fc9f070de3b856bb90906eadcc4fa3
CLEANUP: resolvers: simplify resolv_link_resolution() regarding requesters

This function allocates requesters by hand for each and every type. This
is complex and error-prone, and it doesn't even initialize the list part,
leaving dangling pointers that complicate debugging.

This patch introduces a new function resolv_get_requester() that either
returns the current pointer if valid or tries to allocate a new one and
links it to its destination. Then it makes use of it in the function
above to clean it up quite a bit. This allows to remove complicated but
unneeded tests.

(cherry picked from commit 239675e4a955b219e915fa11a1a03c7aacc13ccd)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit 4d7ca9149914b1188e117608a96b5608232f0bc5)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/dns.c