]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: dns: move callback affection in dns_link_resolution()
authorBaptiste Assmann <bedis9@gmail.com>
Tue, 30 Jan 2018 07:08:04 +0000 (08:08 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 23 Apr 2019 09:34:11 +0000 (11:34 +0200)
In dns.c, dns_link_resolution(), each type of dns requester is managed
separately, that said, the callback function is affected globaly (and
points to server type callbacks only).
This design prevents the addition of new dns requester type and this
patch aims at fixing this limitation: now, the callback setting is done
directly into the portion of code dedicated to each requester type.

src/dns.c

index 46e35ef0a089fc158f113f97e975e08f81683d28..a0da346cfe256c5b2f27ea9d26934c47b051601d 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
@@ -1397,6 +1397,9 @@ int dns_link_resolution(void *requester, int requester_type, int requester_locke
                        req = srv->dns_requester;
                if (!requester_locked)
                        HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock);
+
+               req->requester_cb       = snr_resolution_cb;
+               req->requester_error_cb = snr_resolution_error_cb;
        }
        else if (srvrq) {
                if (srvrq->dns_requester == NULL) {
@@ -1407,13 +1410,14 @@ int dns_link_resolution(void *requester, int requester_type, int requester_locke
                }
                else
                        req = srvrq->dns_requester;
+
+               req->requester_cb       = snr_resolution_cb;
+               req->requester_error_cb = snr_resolution_error_cb;
        }
        else
                goto err;
 
        req->resolution         = res;
-       req->requester_cb       = snr_resolution_cb;
-       req->requester_error_cb = snr_resolution_error_cb;
 
        LIST_ADDQ(&res->requesters, &req->list);
        return 0;