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.
This commit is contained in:
Simon Kelley
2021-06-26 01:00:37 +01:00
parent b908f4334b
commit d515223bb5

View File

@@ -531,7 +531,7 @@ int add_update_server(int flags,
const char *domain, const char *domain,
union all_addr *local_addr) union all_addr *local_addr)
{ {
struct server *serv; struct server *serv = NULL;
char *alloc_domain; char *alloc_domain;
if (!domain || strlen(domain) == 0) if (!domain || strlen(domain) == 0)
@@ -539,12 +539,14 @@ int add_update_server(int flags,
else if (!(alloc_domain = canonicalise((char *)domain, NULL))) else if (!(alloc_domain = canonicalise((char *)domain, NULL)))
return 0; return 0;
/* See if there is a suitable candidate, and unmark */ /* See if there is a suitable candidate, and unmark
for (serv = (flags & SERV_IS_LOCAL) ? daemon->local_domains : daemon->servers; serv; serv = serv->next) only do this for forwarding servers, not
if ((serv->flags & SERV_MARK) && address or local, to avoid delays on large numbers. */
hostname_isequal(alloc_domain, serv->domain) && if (flags & SERV_IS_LOCAL)
((serv->flags & (SERV_6ADDR | SERV_4ADDR)) == (flags & (SERV_6ADDR | SERV_4ADDR)))) for (serv = daemon->servers; serv; serv = serv->next)
break; if ((serv->flags & SERV_MARK) &&
hostname_isequal(alloc_domain, serv->domain))
break;
if (serv) if (serv)
{ {