]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: Fixed tracking number of pending connections to host-port.
authorTimo Sirainen <tss@iki.fi>
Tue, 9 Jul 2013 23:50:04 +0000 (02:50 +0300)
committerTimo Sirainen <tss@iki.fi>
Tue, 9 Jul 2013 23:50:04 +0000 (02:50 +0300)
src/lib-http/http-client-host.c
src/lib-http/http-client-peer.c
src/lib-http/http-client-private.h

index 36095a8fd84e579089b009523a1deacd3b3c6f90..520e820ed0d666e57d457808a96836fcee2b44f5 100644 (file)
@@ -171,7 +171,8 @@ http_client_host_port_connection_setup(struct http_client_host_port *hport)
 
        peer = http_client_peer_get(host->client, &addr);
        http_client_peer_add_host(peer, host);
-       hport->pending_connection_count++;
+       if (http_client_peer_handle_requests(peer))
+               hport->pending_connection_count++;
 
        /* start soft connect time-out (but only if we have another IP left) */
        msecs = host->client->set.soft_connect_timeout_msecs;
index 373c175fc745752e79606e992ba77240e78e7acb..d81e824fd7702173cbe30ebda6f3b2f9119d1c69 100644 (file)
@@ -93,7 +93,8 @@ http_client_peer_requests_pending(struct http_client_peer *peer,
 }
 
 static bool
-http_client_peer_next_request(struct http_client_peer *peer)
+http_client_peer_next_request(struct http_client_peer *peer,
+                             bool *created_connections)
 {
        struct http_client_connection *const *conn_idx;
        struct http_client_connection *conn = NULL;
@@ -161,15 +162,21 @@ http_client_peer_next_request(struct http_client_peer *peer)
                "(already %u usable, connecting to %u, closing %u)",
                new_connections, working_conn_count - connecting,
                connecting, closing);
-       http_client_peer_connect(peer, new_connections);
+       if (new_connections > 0) {
+               *created_connections = TRUE;
+               http_client_peer_connect(peer, new_connections);
+       }
 
        /* now we wait until it is connected */
        return FALSE;
 }
 
-void http_client_peer_handle_requests(struct http_client_peer *peer)
+bool http_client_peer_handle_requests(struct http_client_peer *peer)
 {
-       while (http_client_peer_next_request(peer)) ;
+       bool created_connections = FALSE;
+
+       while (http_client_peer_next_request(peer, &created_connections)) ;
+       return created_connections;
 }
 
 static struct http_client_peer *
@@ -259,7 +266,6 @@ void http_client_peer_add_host(struct http_client_peer *peer,
 {
        if (!http_client_peer_have_host(peer, host))
                array_append(&peer->hosts, &host, 1);
-       http_client_peer_handle_requests(peer);
 }
 
 struct http_client_request *
index dbbad8ccd8d780a6fe6dd78cc222eea230cf0ad8..44e885f60884a733242e2325c2fcc885cffffdee 100644 (file)
@@ -246,7 +246,7 @@ void http_client_peer_add_host(struct http_client_peer *peer,
 struct http_client_request *
        http_client_peer_claim_request(struct http_client_peer *peer,
                bool no_urgent);
-void http_client_peer_handle_requests(struct http_client_peer *peer);
+bool http_client_peer_handle_requests(struct http_client_peer *peer);
 void http_client_peer_connection_success(struct http_client_peer *peer);
 void http_client_peer_connection_failure(struct http_client_peer *peer,
                                         const char *reason);