]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stream: add timeout sample fetches
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 10 Dec 2020 12:43:58 +0000 (13:43 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 11 Dec 2020 11:01:07 +0000 (12:01 +0100)
Add cur_server_timeout and cur_tunnel_timeout.

These sample fetches return the current timeout value for a stream. This
is useful to retrieve the value of a timeout which was changed via a
set-timeout rule.

doc/configuration.txt
src/stream.c

index 8d5a7d2fb7fea60392666d0219213d9b2c2aa82a..7de7087ab1a3af63cdcb9ba7c5c6f8c6f2e404f5 100644 (file)
@@ -16865,6 +16865,16 @@ be_tunnel_timeout : integer
   current backend. This timeout can be overwritten by a "set-timeout" rule. See
   also the "cur_tunnel_timeout".
 
+cur_server_timeout : integer
+  Returns the currently applied server timeout in millisecond for the stream.
+  In the default case, this will be equal to be_server_timeout unless a
+  "set-timeout" rule has been applied. See also "be_server_timeout".
+
+cur_tunnel_timeout : integer
+  Returns the currently applied tunnel timeout in millisecond for the stream.
+  In the default case, this will be equal to be_tunnel_timeout unless a
+  "set-timeout" rule has been applied. See also "be_tunnel_timeout".
+
 dst : ip
   This is the destination IPv4 address of the connection on the client side,
   which is the address the client connected to. It can be useful when running
index 187d8840971f45b6912b86a8c15b0ed203b810c0..6ca1538e806a8d3791f1858cf2602304a263ade8 100644 (file)
@@ -3457,10 +3457,34 @@ static struct action_kw_list stream_http_keywords = { ILH, {
 
 INITCALL1(STG_REGISTER, http_req_keywords_register, &stream_http_keywords);
 
+static int smp_fetch_cur_server_timeout(const struct arg *args, struct sample *smp, const char *km, void *private)
+{
+       smp->flags = SMP_F_VOL_TXN;
+       smp->data.type = SMP_T_SINT;
+       if (!smp->strm)
+               return 0;
+
+       smp->data.u.sint = TICKS_TO_MS(smp->strm->res.rto);
+       return 1;
+}
+
+static int smp_fetch_cur_tunnel_timeout(const struct arg *args, struct sample *smp, const char *km, void *private)
+{
+       smp->flags = SMP_F_VOL_TXN;
+       smp->data.type = SMP_T_SINT;
+       if (!smp->strm)
+               return 0;
+
+       smp->data.u.sint = TICKS_TO_MS(smp->strm->tunnel_timeout);
+       return 1;
+}
+
 /* Note: must not be declared <const> as its list will be overwritten.
  * Please take care of keeping this list alphabetically sorted.
  */
 static struct sample_fetch_kw_list smp_kws = {ILH, {
+       { "cur_server_timeout", smp_fetch_cur_server_timeout, 0, NULL, SMP_T_SINT, SMP_USE_BKEND, },
+       { "cur_tunnel_timeout", smp_fetch_cur_tunnel_timeout, 0, NULL, SMP_T_SINT, SMP_USE_BKEND, },
        { NULL, NULL, 0, 0, 0 },
 }};