BUG/MEDIUM: freq_ctr/threads: use the global_now_ms variable
authorWilly Tarreau <w@1wt.eu>
Tue, 23 Mar 2021 07:58:22 +0000 (08:58 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 31 Mar 2021 07:43:34 +0000 (09:43 +0200)
commit699b67c499c809ce7d11dc447e9d07553c55258d
treed3793eabd34def828b487874099678bad73cfcfa
parente5de69c6a6cea5721a327579b5b32db5278afbcd
BUG/MEDIUM: freq_ctr/threads: use the global_now_ms variable

In commit a1ecbca0a ("BUG/MINOR: freq_ctr/threads: make use of the last
updated global time"), for period-based counters, the millisecond part
of the global_now variable was used as the date for the new period. But
it's wrong, it only works with sub-second periods as it wraps every
second, and for other periods the counters never rotate anymore.

Let's make use of the newly introduced global_now_ms variable instead,
which contains the global monotonic time expressed in milliseconds.

This patch needs to be backported wherever the patch above is backported.
It depends on previous commit "MINOR: time: also provide a global,
monotonic global_now_ms timer".

(cherry picked from commit 8cc586c73fefd96f4be1f7820e38a1263f6252ca)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit 049602fff734664afbf75b5b28b1d9a028ed9f04)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit 84c81577e52b7376e2c03cfd552d3023fa4349ec)
Signed-off-by: Willy Tarreau <w@1wt.eu>
include/proto/freq_ctr.h
src/freq_ctr.c