From 172c3809dda147f6a8db306e1b165c419f2794ed Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Tue, 15 Jun 2021 16:14:37 +0200 Subject: [PATCH] MINOR: resolvers: Remove server from named_servers tree when removing a SRV item When a server is cleaned up because the corresponding SRV item is removed, we always remove the server from the srvrq's name_servers tree. For now, it is useless because, if a server was attached to a SRV item, it means it was already removed from the tree. But it will be mandatory to fix a bug. (cherry picked from commit 73001ab6e39fb25ff406bbcd3809d0a1fa0131b5) Signed-off-by: Christopher Faulet (cherry picked from commit a62d9743fd4efaab5e08c94229af390e4afcd17a) [cf: Changes applied in src/dns.c instead of src/resolvers.c] Signed-off-by: Christopher Faulet --- src/dns.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/dns.c b/src/dns.c index e95e11b..1733fae 100644 --- a/src/dns.c +++ b/src/dns.c @@ -646,6 +646,11 @@ static void dns_srvrq_cleanup_srv(struct server *srv) memset(&srv->addr, 0, sizeof(srv->addr)); srv->svc_port = 0; srv->flags |= SRV_F_NO_RESOLUTION; + + ebpt_delete(&srv->host_dn); + free(srv->host_dn.key); + srv->host_dn.key = NULL; + HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock); LIST_DEL(&srv->srv_rec_item); LIST_ADDQ(&srv->srvrq->attached_servers, &srv->srv_rec_item); @@ -744,6 +749,7 @@ static void dns_check_dns_response(struct dns_resolution *res) /* server found, we remove it from tree */ ebpt_delete(node); free(srv->host_dn.key); + srv->host_dn.key = NULL; goto srv_found; } -- 1.7.10.4