From b02906659b510c0c6c052d8aedff54adee395e95 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 13 Jun 2014 17:04:44 +0200 Subject: [PATCH] MEDIUM: session: allow shorter retry delay if timeout connect is small As discussed with Dmitry Sivachenko, the default 1-second connect retry delay can be large for situations where the connect timeout is much smaller, because it means that an active connection reject will take more time to be retried than a silent drop, and that does not make sense. This patch changes this so that the retry delay is the minimum of 1 second and the connect timeout. That way people running with sub-second connect timeout will benefit from the shorter reconnect. --- src/session.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/session.c b/src/session.c index cfb45c8ce..414ff65c6 100644 --- a/src/session.c +++ b/src/session.c @@ -899,14 +899,19 @@ static int sess_update_st_cer(struct session *s, struct stream_interface *si) /* The error was an asynchronous connection error, and we will * likely have to retry connecting to the same server, most * likely leading to the same result. To avoid this, we wait - * one second before retrying. + * MIN(one second, connect timeout) before retrying. */ + int delay = 1000; + + if (s->be->timeout.connect && s->be->timeout.connect < delay) + delay = s->be->timeout.connect; + if (!si->err_type) si->err_type = SI_ET_CONN_ERR; si->state = SI_ST_TAR; - si->exp = tick_add(now_ms, MS_TO_TICKS(1000)); + si->exp = tick_add(now_ms, MS_TO_TICKS(delay)); return 0; } return 0;