]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: stream: support a dynamic server timeout
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 10 Dec 2020 12:43:52 +0000 (13:43 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 11 Dec 2020 11:01:07 +0000 (12:01 +0100)
Allow the modification of the timeout server value on the stream side.
Do not apply the default backend server timeout in back_establish if it
is already defined. This is the case if a set-timeout server rule has
been executed.

src/stream.c

index 65c67d10ea06a088bfe89ebe565ecb5a9c39a53f..bed65b266fc9bc44f34ea1b7d1e44868d045f4b4 100644 (file)
@@ -813,7 +813,15 @@ void stream_process_counters(struct stream *s)
 
 int stream_set_timeout(struct stream *s, enum act_timeout_name name, int timeout)
 {
-       return 0;
+       switch (name) {
+       case ACT_TIMEOUT_SERVER:
+               s->req.wto = timeout;
+               s->res.rto = timeout;
+               return 1;
+
+       default:
+               return 0;
+       }
 }
 
 /*
@@ -884,9 +892,15 @@ static void back_establish(struct stream *s)
        si_rx_endp_more(si);
        rep->flags |= CF_READ_ATTACHED; /* producer is now attached */
        if (objt_cs(si->end)) {
-               /* real connections have timeouts */
-               req->wto = s->be->timeout.server;
-               rep->rto = s->be->timeout.server;
+               /* real connections have timeouts
+                * if already defined, it means that a set-timeout rule has
+                * been executed so do not overwrite them
+                */
+               if (!tick_isset(req->wto))
+                       req->wto = s->be->timeout.server;
+               if (!tick_isset(rep->rto))
+                       rep->rto = s->be->timeout.server;
+
                /* The connection is now established, try to read data from the
                 * underlying layer, and subscribe to recv events. We use a
                 * delayed recv here to give a chance to the data to flow back