BUG/MINOR: resolvers: Unlink DNS resolution to set RMAINT on SRV resolution
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 10 Mar 2021 20:33:21 +0000 (21:33 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 16 Mar 2021 08:09:03 +0000 (09:09 +0100)
When a server is set in RMAINT becaues of a SRV resolution failure, the
server DNS resolution, if any, must be unlink first. It is mandatory to
handle the change in the context of a SRV resolution.

This patch must be backported as far as 2.2.

(cherry picked from commit bca680ba90787fc57b9711e268f6fb0c74e7e49c)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

src/dns.c
src/server.c

index da0076d..06b4d80 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
@@ -619,6 +619,7 @@ static void dns_check_dns_response(struct dns_resolution *res)
                                        if (srv->srvrq == srvrq && srv->svc_port == item->port &&
                                            item->data_len == srv->hostname_dn_len &&
                                            !dns_hostname_cmp(srv->hostname_dn, item->target, item->data_len)) {
+                                               dns_unlink_resolution(srv->dns_requester);
                                                snr_update_srv_status(srv, 1);
                                                free(srv->hostname);
                                                free(srv->hostname_dn);
@@ -627,7 +628,6 @@ static void dns_check_dns_response(struct dns_resolution *res)
                                                srv->hostname_dn_len = 0;
                                                memset(&srv->addr, 0, sizeof(srv->addr));
                                                srv->svc_port = 0;
-                                               dns_unlink_resolution(srv->dns_requester);
                                        }
                                        HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock);
                                }
index a90e568..dd82d9b 100644 (file)
@@ -3963,6 +3963,7 @@ int srvrq_resolution_error_cb(struct dns_requester *requester, int error_code)
        for (s = srvrq->proxy->srv; s != NULL; s = s->next) {
                HA_SPIN_LOCK(SERVER_LOCK, &s->lock);
                if (s->srvrq == srvrq) {
+                       dns_unlink_resolution(s->dns_requester);
                        snr_update_srv_status(s, 1);
                        free(s->hostname);
                        free(s->hostname_dn);
@@ -3971,7 +3972,6 @@ int srvrq_resolution_error_cb(struct dns_requester *requester, int error_code)
                        s->hostname_dn_len = 0;
                        memset(&s->addr, 0, sizeof(s->addr));
                        s->svc_port = 0;
-                       dns_unlink_resolution(s->dns_requester);
                }
                HA_SPIN_UNLOCK(SERVER_LOCK, &s->lock);
        }