]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: session: allow shorter retry delay if timeout connect is small
authorWilly Tarreau <w@1wt.eu>
Fri, 13 Jun 2014 15:04:44 +0000 (17:04 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 13 Jun 2014 15:04:44 +0000 (17:04 +0200)
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

index cfb45c8ce210cac619fbca3922ab7fe3e98ba93d..414ff65c69140d6dead1aaa939e44c85d0aa368d 100644 (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;