]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: client: Fixed race condition between DNS refresh lookup and a soft connecti...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Mon, 3 Apr 2017 22:32:07 +0000 (00:32 +0200)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Fri, 26 May 2017 06:07:01 +0000 (09:07 +0300)
The refreshing DNS lookup cleared all the IPs, but the soft connection timeout (and maybe other code) still relied on them.
Adding tests everywhere for host->ips_count == 0 is annoying, so I changed the DNS lookup code such that the stale IPs remain present while the DNS lookup is being performed.
The pending lookup prevents new connections through http_client_host_refresh(), so this will not create potentially useless connections.

src/lib-http/http-client-host.c

index b6f68f6981aa61c519732fd0b45c59a9caccfbca..dc3e59238598ccdf6c32a1547114cb7e75bbdf24 100644 (file)
@@ -108,8 +108,6 @@ static void http_client_host_lookup
        i_assert(!host->explicit_ip);
        i_assert(host->dns_lookup == NULL);
 
-       host->ips_count = 0;
-
        if (client->set.dns_client != NULL) {
                http_client_host_debug(host,
                        "Performing asynchronous DNS lookup");
@@ -147,9 +145,7 @@ static void http_client_host_lookup
                host->ips_count = ips_count;
                host->ips = i_new(struct ip_addr, ips_count);
                memcpy(host->ips, ips, ips_count * sizeof(*ips));
-       }
 
-       if (host->ips_count > 0) {
                host->ips_timeout = ioloop_timeval;
                timeval_add_msecs(&host->ips_timeout, client->set.dns_ttl_msecs);
        }