From d515223bb5802d25b5148e313fe3f930c98a24f2 Mon Sep 17 00:00:00 2001 From: Simon Kelley Date: Sat, 26 Jun 2021 01:00:37 +0100 Subject: [PATCH] Don't re-use datastructures for --address and --local. Doing so makes the loading process quadratic, which is a problem when there are a large number. --- src/domain-match.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/domain-match.c b/src/domain-match.c index 337bd1e..473d0b2 100644 --- a/src/domain-match.c +++ b/src/domain-match.c @@ -531,7 +531,7 @@ int add_update_server(int flags, const char *domain, union all_addr *local_addr) { - struct server *serv; + struct server *serv = NULL; char *alloc_domain; if (!domain || strlen(domain) == 0) @@ -539,12 +539,14 @@ int add_update_server(int flags, else if (!(alloc_domain = canonicalise((char *)domain, NULL))) return 0; - /* See if there is a suitable candidate, and unmark */ - for (serv = (flags & SERV_IS_LOCAL) ? daemon->local_domains : daemon->servers; serv; serv = serv->next) - if ((serv->flags & SERV_MARK) && - hostname_isequal(alloc_domain, serv->domain) && - ((serv->flags & (SERV_6ADDR | SERV_4ADDR)) == (flags & (SERV_6ADDR | SERV_4ADDR)))) - break; + /* See if there is a suitable candidate, and unmark + only do this for forwarding servers, not + address or local, to avoid delays on large numbers. */ + if (flags & SERV_IS_LOCAL) + for (serv = daemon->servers; serv; serv = serv->next) + if ((serv->flags & SERV_MARK) && + hostname_isequal(alloc_domain, serv->domain)) + break; if (serv) {