From d97d1d7c7c654d1a9e2e712ac7736420fe2d6ea5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20L=C3=A9caille?= Date: Mon, 6 Feb 2023 09:23:56 +0100 Subject: [PATCH] BUG/MINOR: stats: Prevent HTTP "other sessions" counter underflows 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 | 1 + 1 file changed, 1 insertion(+) diff --git a/src/stats.c b/src/stats.c index 62e372a7b..960fcbf5f 100644 --- a/src/stats.c +++ b/src/stats.c @@ -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; }