]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: Fixed a hang
authorTimo Sirainen <tss@iki.fi>
Wed, 26 Mar 2014 15:17:34 +0000 (16:17 +0100)
committerTimo Sirainen <tss@iki.fi>
Wed, 26 Mar 2014 15:17:34 +0000 (16:17 +0100)
Patch by Stephan Bosch

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

index 12439101500a2c8e7d2b609b5bdf6c1a79aca5fe..387f46f7b223c86a3049837f358587e0acec3917 100644 (file)
@@ -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;