dovecot-2.2: lib-http: Fixed tracking number of pending connecti...

dovecot at dovecot.org dovecot at dovecot.org
Wed Jul 10 02:50:09 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/129ae6342b28
changeset: 16579:129ae6342b28
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Jul 10 02:50:04 2013 +0300
description:
lib-http: Fixed tracking number of pending connections to host-port.

diffstat:

 src/lib-http/http-client-host.c    |   3 ++-
 src/lib-http/http-client-peer.c    |  16 +++++++++++-----
 src/lib-http/http-client-private.h |   2 +-
 3 files changed, 14 insertions(+), 7 deletions(-)

diffs (71 lines):

diff -r 843208699cbc -r 129ae6342b28 src/lib-http/http-client-host.c
--- a/src/lib-http/http-client-host.c	Wed Jul 10 02:31:05 2013 +0300
+++ b/src/lib-http/http-client-host.c	Wed Jul 10 02:50:04 2013 +0300
@@ -171,7 +171,8 @@
 
 	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;
diff -r 843208699cbc -r 129ae6342b28 src/lib-http/http-client-peer.c
--- a/src/lib-http/http-client-peer.c	Wed Jul 10 02:31:05 2013 +0300
+++ b/src/lib-http/http-client-peer.c	Wed Jul 10 02:50:04 2013 +0300
@@ -93,7 +93,8 @@
 }
 
 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 @@
 		"(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 @@
 {
 	if (!http_client_peer_have_host(peer, host))
 		array_append(&peer->hosts, &host, 1);
-	http_client_peer_handle_requests(peer);
 }
 
 struct http_client_request *
diff -r 843208699cbc -r 129ae6342b28 src/lib-http/http-client-private.h
--- a/src/lib-http/http-client-private.h	Wed Jul 10 02:31:05 2013 +0300
+++ b/src/lib-http/http-client-private.h	Wed Jul 10 02:50:04 2013 +0300
@@ -246,7 +246,7 @@
 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);


More information about the dovecot-cvs mailing list