]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: sample: also support retrieving fc.timer.handshake without a stream
authorWilly Tarreau <w@1wt.eu>
Sun, 11 Jan 2026 14:13:42 +0000 (15:13 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 11 Jan 2026 14:48:19 +0000 (15:48 +0100)
Some timers, like the handshake timer, are stored in the session and are
only copied to the logs struct when a stream is created. But this means
we can't measure it without a stream, nor store it once for all in a
variable at session creation time. Let's extend the sample fetch function
to retrieve it from the session when no stream is present. The doc did not
mention this limitation so this could almost be considered as a bug.

src/sample.c

index 0473dc86cb259df5c23cc8d838e4b30ee22fe11b..31fe56fd84ef14a8c83c1d4fc129daa351df5cf0 100644 (file)
@@ -5381,12 +5381,20 @@ static int smp_fetch_conn_timers(const struct arg *args, struct sample *smp, con
 {
        struct strm_logs *logs;
 
-       if (!smp->strm)
-               return 0;
-
        smp->data.type = SMP_T_SINT;
        smp->flags = 0;
 
+       if (!smp->strm) {
+               /* no stream: only fc.timer.handshake is available via
+                * the session.
+                */
+               if (kw[0] == 'f' && kw[9] == 'h') {
+                       smp->data.u.sint = smp->sess->t_handshake;
+                       return 1;
+               }
+               return 0;
+       }
+
        logs = &smp->strm->logs;
 
        if (kw[0] == 'b') {