]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: stats: Prevent HTTP "other sessions" counter underflows
authorFrédéric Lécaille <flecaille@haproxy.com>
Mon, 6 Feb 2023 08:23:56 +0000 (09:23 +0100)
committerFrédéric Lécaille <flecaille@haproxy.com>
Mon, 6 Feb 2023 13:04:27 +0000 (14:04 +0100)
Due to multithreading concurrency, it is difficult at this time to figure
out how this counter may become negative. This simple patch only checks this
will never be the case.

This issue arrives with this commit:
 "9969adbcdc MINOR: stats: add by HTTP version cumulated number of sessions and requests"
So, this patch should be backported when the latter has been backported.

src/stats.c

index 62e372a7ba6549319b04a9a38891ae554cf7c72c..960fcbf5f6cc294929801d0487d3bd2ef58ff528 100644 (file)
@@ -1876,6 +1876,7 @@ int stats_fill_fe_stats(struct proxy *px, struct field *stats, int len,
                                total_sess = px->fe_counters.cum_sess;
                                for (i = 0; i < nb_sess; i++)
                                        total_sess -= px->fe_counters.cum_sess_ver[i];
+                               total_sess = (int64_t)total_sess < 0 ? 0 : total_sess;
                                metric = mkf_u64(FN_COUNTER, total_sess);
                                break;
                        }