Skip to content

Commit

Permalink
lib-http: client: Fixed race condition between DNS refresh lookup and…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
stephanbosch authored and GitLab committed May 3, 2017
1 parent f950619 commit 4ef9997
Showing 1 changed file with 0 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/lib-http/http-client-host.c
Expand Up @@ -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");
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 4ef9997

Please sign in to comment.