From: Baptiste Assmann Date: Tue, 30 Jan 2018 07:08:04 +0000 (+0100) Subject: MINOR: dns: move callback affection in dns_link_resolution() X-Git-Tag: v2.0-dev3~195 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db4c8521caefcc8ec2a26f60b4659019dc94e54d;p=thirdparty%2Fhaproxy.git MINOR: dns: move callback affection in dns_link_resolution() 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. --- diff --git a/src/dns.c b/src/dns.c index 46e35ef0a0..a0da346cfe 100644 --- 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;