]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: sample: Fix sample to retrieve the number of bytes received and sent
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 5 Mar 2026 08:58:59 +0000 (09:58 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 5 Mar 2026 14:34:47 +0000 (15:34 +0100)
There was an issue in the if/else statement in smp_fetch_bytes() function.
When req.bytes_in or req.bytes_out was requested, res.bytes_in was always
returned. It is now fixed.

This patch must be backported to 3.3.

src/sample.c

index 7e3d195dcb26e7f0a52a8561c9b38e69eb48b629..f8150eaa53be633eed41506aaa5b4a04ef4fe4e1 100644 (file)
@@ -5543,7 +5543,7 @@ static int smp_fetch_bytes(const struct arg *args, struct sample *smp, const cha
 
        if (kw[2] == 'q') /* req.bytes_in or req.bytes_out */
                smp->data.u.sint = (kw[10] == 'i') ? logs->req_in : logs->req_out;
-       if (kw[2] == 's') /* res.bytes_in or res.bytes_out */
+       else if (kw[2] == 's') /* res.bytes_in or res.bytes_out */
                smp->data.u.sint = (kw[10] == 'i') ? logs->res_in : logs->res_out;
        else /* bytes_in or bytes_out */
                smp->data.u.sint = (kw[6] == 'i') ? logs->req_in : logs->res_in;