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.
This commit is contained in:
Frédéric Lécaille 2023-02-06 09:23:56 +01:00
parent b7a406ac34
commit d97d1d7c7c

View 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;
}