]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: http-client-host - Make sure DNS lookup is performed when host has no IPs.
authorStephan Bosch <stephan.bosch@open-xchange.com>
Tue, 22 Sep 2020 20:12:27 +0000 (22:12 +0200)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 7 Oct 2020 11:58:33 +0000 (14:58 +0300)
This fixes at least one panic:

Panic: file ./http-client-private.h: line 679 (http_client_host_get_ip): assertion failed: (idx < host->shared->ips_count)

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

index 27126eebdb5942ec16e312d2abc1408b26b8a582..2168795b68c46578acbfa3b36c775f40d881418d 100644 (file)
@@ -187,14 +187,15 @@ http_client_host_shared_refresh(struct http_client_host_shared *hshared)
        if (hshared->dns_lookup != NULL)
                return -1;
 
-       if (hshared->ips_count > 0 &&
-           timeval_cmp(&hshared->ips_timeout, &ioloop_timeval) > 0)
-               return 0;
-
-       if (hshared->to_idle != NULL)
-               return 0;
+       if (hshared->ips_count == 0) {
+               e_debug(hshared->event, "Need to perform DNS lookup");
+       } else {
+               if (timeval_cmp(&hshared->ips_timeout, &ioloop_timeval) > 0)
+                       return 0;
 
-       e_debug(hshared->event, "IPs have expired; need to refresh DNS lookup");
+               e_debug(hshared->event, "IPs have expired; "
+                       "need to refresh DNS lookup");
+       }
 
        http_client_host_shared_lookup(hshared);
        if (hshared->dns_lookup != NULL)