]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: client: Fixed i_unreached() failure occurring when a host's list of IPs...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Thu, 23 Feb 2017 18:38:31 +0000 (19:38 +0100)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 23 Feb 2017 19:21:13 +0000 (21:21 +0200)
In that case, the IP of the pending connection may no longer be associated with that host.
If the IP was not found anymore, the i_unreached() error occurred.

src/lib-http/http-client-private.h
src/lib-http/http-client-queue.c

index e22407a2ed1abe243d10f1a4239973fd0f1c18af..83c755c0757e9d4b99693027115335bbc537bc5f 100644 (file)
@@ -516,17 +516,19 @@ void http_client_queue_switch_ioloop(struct http_client_queue *queue);
  * Host
  */
 
-static inline unsigned int
+static inline bool
 http_client_host_get_ip_idx(struct http_client_host *host,
-                           const struct ip_addr *ip)
+                           const struct ip_addr *ip, unsigned int *idx_r)
 {
        unsigned int i;
 
        for (i = 0; i < host->ips_count; i++) {
-               if (net_ip_compare(&host->ips[i], ip))
-                       return i;
+               if (net_ip_compare(&host->ips[i], ip)) {
+                       *idx_r = i;
+                       return TRUE;
+               }
        }
-       i_unreached();
+       return FALSE;
 }
 
 struct http_client_host *
index ba3e668d5f6bcb2c04ab9279d1e662d3da943890..6aa1893fbffe66806bb32d8e0e8d72466649815b 100644 (file)
@@ -430,8 +430,11 @@ http_client_queue_connection_success(struct http_client_queue *queue,
        if (queue->host->dns_lookup == NULL &&
                queue->addr.type != HTTP_CLIENT_PEER_ADDR_UNIX) {
                /* we achieved at least one connection the the addr->ip */
-               queue->ips_connect_start_idx =
-                       http_client_host_get_ip_idx(queue->host, &addr->a.tcp.ip);
+               if (!http_client_host_get_ip_idx(queue->host,
+                       &addr->a.tcp.ip, &queue->ips_connect_start_idx)) {
+                       /* list of IPs changed during connect */
+                       queue->ips_connect_start_idx = 0;
+               }
        }
 
        /* reset attempt counter */