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.
This commit is contained in:
Willy Tarreau 2014-06-13 17:04:44 +02:00
parent 18bf01e900
commit b02906659b

View File

@ -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;