From: Willy Tarreau Date: Fri, 13 Jun 2014 15:04:44 +0000 (+0200) Subject: MEDIUM: session: allow shorter retry delay if timeout connect is small X-Git-Tag: v1.5.0~34 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b02906659b510c0c6c052d8aedff54adee395e95;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/src/session.c b/src/session.c index cfb45c8ce2..414ff65c69 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;