]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: resolvers: Don't try to match immediatly renewed ADD items
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 12 Mar 2021 15:42:45 +0000 (16:42 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 12 Mar 2021 16:42:45 +0000 (17:42 +0100)
The loop looking for existing ADD items to renew their last_seen must ignore
the items already renewed in the same loop. To do so, we rely on the
last_seen time. because it is now based on now_ms, it is safe.

Doing so avoid to match several time the same ADD item when the same IP
address is found in several ADD item. This reduces the number of extra DNS
resolutions.

This patch depends on "MINOR: resolvers: Use milliseconds for cached items
in resolver responses". Both may be backported as far as 2.2 if necessary.

src/resolvers.c

index 8c09b7b09c644e8720d24609a8c7b9630af4ed38..2d79725b752725843c2a062b512474411326baee 100644 (file)
@@ -1250,7 +1250,7 @@ static int resolv_validate_dns_response(unsigned char *resp, unsigned char *bufe
                                continue;
 
                        ar_item = tmp_record->ar_item;
-                       if (ar_item->type != answer_record->type ||
+                       if (ar_item->type != answer_record->type || ar_item->last_seen == now_ms ||
                            len != tmp_record->data_len ||
                            resolv_hostname_cmp(answer_record->name, tmp_record->target, tmp_record->data_len))
                                continue;