]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: dns: enable caching of responses for server set by a SRV record
authorBaptiste Assmann <bedis9@gmail.com>
Mon, 14 Aug 2017 14:35:45 +0000 (16:35 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 18 Aug 2017 09:25:41 +0000 (11:25 +0200)
The function srv_set_fqdn() is used to update a server's fqdn and set
accordingly its DNS resolution.
Current implementation prevents a server whose update is triggered by a
SRV record from being linked to an existing resolution in the cache (if
applicable).
This patch aims at fixing this.

src/server.c

index cfbdb3d715142ca73c57a1e19acdf0055c7b9009..caf84c6ae0aacfb280a140d9fa4522739f9f4b7f 100644 (file)
@@ -4133,9 +4133,14 @@ int srv_set_fqdn(struct server *srv, const char *hostname)
                /* first, we need to unlink our server from its current resolution */
                srv_free_from_resolution(srv);
        } else {
-               resolution = srv->resolution;
-               resolution->last_resolution = now_ms;
-               did_set_reso = 1;
+               /* this server's fqdn has been set by a SRV record */
+               resolution = dns_resolution_list_get(srv->resolvers, trash.str, srv->dns_requester->prefered_query_type);
+               srv_free_from_resolution(srv);
+               srv->resolution = resolution;
+               if (resolution->hostname_dn == NULL) {
+                       resolution->last_resolution = now_ms;
+                       did_set_reso = 1;
+               }
        }
 
        /* now we update server's parameters */