From: Timo Sirainen Date: Wed, 26 Mar 2014 15:17:34 +0000 (+0100) Subject: lib-http: Fixed a hang X-Git-Tag: 2.2.13.rc1~191 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=028a1c8de5166a81c2394131cac2406327febf52;p=thirdparty%2Fdovecot%2Fcore.git lib-http: Fixed a hang Patch by Stephan Bosch --- diff --git a/src/lib-http/http-client-queue.c b/src/lib-http/http-client-queue.c index 1243910150..387f46f7b2 100644 --- a/src/lib-http/http-client-queue.c +++ b/src/lib-http/http-client-queue.c @@ -228,11 +228,24 @@ void http_client_queue_connection_setup(struct http_client_queue *queue) if (!http_client_peer_is_connected(peer)) { unsigned int msecs; + bool new_peer = TRUE; /* not already connected, wait for connections */ if (!array_is_created(&queue->pending_peers)) i_array_init(&queue->pending_peers, 8); - array_append(&queue->pending_peers, &peer, 1); + else { + struct http_client_peer *const *peer_idx; + + /* we may be waiting for this peer already */ + array_foreach(&queue->pending_peers, peer_idx) { + if (http_client_peer_addr_cmp(&(*peer_idx)->addr, addr) == 0) { + new_peer = FALSE; + break; + } + } + } + if (new_peer) + array_append(&queue->pending_peers, &peer, 1); /* start soft connect time-out (but only if we have another IP left) */ msecs = host->client->set.soft_connect_timeout_msecs;