From: Frédéric Lécaille Date: Mon, 6 Feb 2023 08:23:56 +0000 (+0100) Subject: BUG/MINOR: stats: Prevent HTTP "other sessions" counter underflows X-Git-Tag: v2.8-dev4~35 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d97d1d7c7c654d1a9e2e712ac7736420fe2d6ea5;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/src/stats.c b/src/stats.c index 62e372a7ba..960fcbf5f6 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; }