From: Stephan Bosch Date: Mon, 3 Apr 2017 22:32:07 +0000 (+0200) Subject: lib-http: client: Fixed race condition between DNS refresh lookup and a soft connecti... X-Git-Tag: 2.2.31.rc1~183 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=05e721c729fa857deb188d5d04f2200c7dcf4983;p=thirdparty%2Fdovecot%2Fcore.git lib-http: client: Fixed race condition between DNS refresh lookup and a soft connection timeout. 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. --- diff --git a/src/lib-http/http-client-host.c b/src/lib-http/http-client-host.c index b6f68f6981..dc3e592385 100644 --- a/src/lib-http/http-client-host.c +++ b/src/lib-http/http-client-host.c @@ -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); }