From 27c8d7a5321ba0a091da5e0dc56911135c24d8a3 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Fri, 12 Mar 2021 16:42:45 +0100 Subject: [PATCH] MINOR: resolvers: Don't try to match immediatly renewed ADD items 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. (cherry picked from commit e8674c71840cd783d6ba1cc073c0d074aea09fd8) Signed-off-by: Christopher Faulet --- src/dns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dns.c b/src/dns.c index c9ffcf7..07bdde5 100644 --- a/src/dns.c +++ b/src/dns.c @@ -1302,7 +1302,7 @@ static int dns_validate_dns_response(unsigned char *resp, unsigned char *bufend, continue; ar_item = tmp_record->ar_item; - if (ar_item->type != dns_answer_record->type || + if (ar_item->type != dns_answer_record->type || ar_item->last_seen == now_ms || len != tmp_record->data_len || dns_hostname_cmp(dns_answer_record->name, tmp_record->target, tmp_record->data_len)) continue; -- 1.7.10.4