dovecot-2.2: lib-http: client: Implemented maximum for connectio...

dovecot at dovecot.org dovecot at dovecot.org
Thu Oct 23 02:56:51 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/44fd142fac1e
changeset: 17986:44fd142fac1e
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Thu Oct 23 05:55:51 2014 +0300
description:
lib-http: client: Implemented maximum for connection backoff time.
Without a maximum, the backoff time grows exponentially to enormous values,
because it isn't reset until the connection succeeds. This causes recovery
from connection failures to become very slow. Current maximum is one
minute.

diffstat:

 src/lib-http/http-client-peer.c    |  2 ++
 src/lib-http/http-client-private.h |  1 +
 src/lib-http/http-client.c         |  4 ++++
 src/lib-http/http-client.h         |  2 ++
 4 files changed, 9 insertions(+), 0 deletions(-)

diffs (49 lines):

diff -r e479bce0633b -r 44fd142fac1e src/lib-http/http-client-peer.c
--- a/src/lib-http/http-client-peer.c	Thu Oct 23 05:55:51 2014 +0300
+++ b/src/lib-http/http-client-peer.c	Thu Oct 23 05:55:51 2014 +0300
@@ -592,6 +592,8 @@
 			peer->backoff_time_msecs = set->connect_backoff_time_msecs;
 		else
 			peer->backoff_time_msecs *= 2;
+		if (peer->backoff_time_msecs > set->connect_backoff_max_time_msecs)
+			peer->backoff_time_msecs = set->connect_backoff_max_time_msecs;
 	}
 
 	if (pending > 1) {
diff -r e479bce0633b -r 44fd142fac1e src/lib-http/http-client-private.h
--- a/src/lib-http/http-client-private.h	Thu Oct 23 05:55:51 2014 +0300
+++ b/src/lib-http/http-client-private.h	Thu Oct 23 05:55:51 2014 +0300
@@ -14,6 +14,7 @@
 #define HTTP_CLIENT_CONTINUE_TIMEOUT_MSECS (1000*2)
 #define HTTP_CLIENT_DEFAULT_REQUEST_TIMEOUT_MSECS (1000*60*5)
 #define HTTP_CLIENT_DEFAULT_BACKOFF_TIME_MSECS (100)
+#define HTTP_CLIENT_DEFAULT_BACKOFF_MAX_TIME_MSECS (1000*60)
 
 enum http_response_payload_type;
 
diff -r e479bce0633b -r 44fd142fac1e src/lib-http/http-client.c
--- a/src/lib-http/http-client.c	Thu Oct 23 05:55:51 2014 +0300
+++ b/src/lib-http/http-client.c	Thu Oct 23 05:55:51 2014 +0300
@@ -125,6 +125,10 @@
 		set->connect_backoff_time_msecs == 0 ?
 			HTTP_CLIENT_DEFAULT_BACKOFF_TIME_MSECS :
 			set->connect_backoff_time_msecs;
+	client->set.connect_backoff_max_time_msecs =
+		set->connect_backoff_max_time_msecs == 0 ?
+			HTTP_CLIENT_DEFAULT_BACKOFF_MAX_TIME_MSECS :
+			set->connect_backoff_max_time_msecs;
 	client->set.no_auto_redirect = set->no_auto_redirect;
 	client->set.no_ssl_tunnel = set->no_ssl_tunnel;
 	client->set.max_redirects = set->max_redirects;
diff -r e479bce0633b -r 44fd142fac1e src/lib-http/http-client.h
--- a/src/lib-http/http-client.h	Thu Oct 23 05:55:51 2014 +0300
+++ b/src/lib-http/http-client.h	Thu Oct 23 05:55:51 2014 +0300
@@ -95,6 +95,8 @@
 
 	/* Initial backoff time; doubled at each connection failure */
 	unsigned int connect_backoff_time_msecs;
+	/* Maximum backoff time */
+	unsigned int connect_backoff_max_time_msecs;
 
 	/* response header limits */
 	struct http_header_limits response_hdr_limits;


More information about the dovecot-cvs mailing list