dovecot-2.2: lib-http: When successfully connected to a peer, do...

dovecot at dovecot.org dovecot at dovecot.org
Thu Jun 27 22:59:29 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/e405105a0c24
changeset: 16573:e405105a0c24
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Jun 27 22:49:50 2013 +0300
description:
lib-http: When successfully connected to a peer, don't drop the peer's pending connections.
They could have been intentionally created for other urgent requests.

diffstat:

 src/lib-http/http-client-host.c |  22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)

diffs (60 lines):

diff -r 20a0595e6e5d -r e405105a0c24 src/lib-http/http-client-host.c
--- a/src/lib-http/http-client-host.c	Thu Jun 27 20:37:46 2013 +0300
+++ b/src/lib-http/http-client-host.c	Thu Jun 27 22:49:50 2013 +0300
@@ -169,13 +169,21 @@
 }
 
 static void
-http_client_host_drop_pending_connections(struct http_client_host_port *hport)
+http_client_host_drop_pending_connections(struct http_client_host_port *hport,
+					  const struct http_client_peer_addr *addr)
 {
 	struct http_client_peer *peer;
 	struct http_client_connection *const *conns, *conn;
 	unsigned int i, count;
 
 	for (peer = hport->host->client->peers_list; peer != NULL; peer = peer->next) {
+		if (http_client_peer_addr_cmp(&peer->addr, addr) == 0) {
+			/* don't drop any connections to the successfully
+			   connected peer, even if some of the connections
+			   are pending. they may be intended for urgent
+			   requests. */
+			continue;
+		}
 		if (!http_client_peer_have_host(peer, hport->host))
 			continue;
 
@@ -193,7 +201,8 @@
 }
 
 static void
-http_client_host_port_connection_success(struct http_client_host_port *hport)
+http_client_host_port_connection_success(struct http_client_host_port *hport,
+					 const struct http_client_peer_addr *addr)
 {
 	/* we achieved at least one connection the the addr->ip */
 
@@ -201,10 +210,11 @@
 	if (hport->to_connect != NULL)
 		timeout_remove(&hport->to_connect);
 
-	/* drop all other attempts. note that we get here whenever a connection
-	   is successfully created, so pending_connection_count may be 0. */
+	/* drop all other attempts to the hport. note that we get here whenever
+	   a connection is successfully created, so pending_connection_count
+	   may be 0. */
 	if (hport->pending_connection_count > 1)
-		http_client_host_drop_pending_connections(hport);
+		http_client_host_drop_pending_connections(hport, addr);
 	/* since this hport is now successfully connected, we won't be
 	   getting any connection failures to it anymore. so we need
 	   to reset the pending_connection_count count here. */
@@ -257,7 +267,7 @@
 	if (hport == NULL)
 		return;
 
-	http_client_host_port_connection_success(hport);
+	http_client_host_port_connection_success(hport, addr);
 }
 
 void http_client_host_connection_failure(struct http_client_host *host,


More information about the dovecot-cvs mailing list