]> 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)
committerGitLab <gitlab@git.dovecot.net>
Wed, 3 May 2017 11:08:33 +0000 (14:08 +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 3005c322ed07cb85f3dbe42b26afd9621a66b587..6ec76c1973e05cb84c4057c8973b250b1cac213e 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);
        }