]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: freq_ctr: add a generic function to report the total value
authorWilly Tarreau <w@1wt.eu>
Sat, 10 Apr 2021 22:38:06 +0000 (00:38 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 11 Apr 2021 09:10:57 +0000 (11:10 +0200)
commitf3a9f8dc5a88837760127947a58365d489a03d54
treea983618ab430c417a50d4bee1fa5e701361d0eb3
parent6eb3d37bf45844789a7118d259ea14dc0b398a51
MINOR: freq_ctr: add a generic function to report the total value

Most of the functions designed to read a counter over a period go through
the same complex loop and only differ in the way they use the returned
values, so it was worth implementing all this into freq_ctr_total() which
returns the total number of events over a period so that the caller can
finish its operation using a divide or a remaining time calculation. As
a special case, read_freq_ctr_period() doesn't take pending events but
requires to enable an anti-flapping correction at very low frequencies.
Thus the function implements it when pend<0.

Thanks to this function it will be possible to reimplement the other ones
as inline and merge the per-second ones with the arbitrary period ones
without always adding the cost of a 64 bit divide.
include/haproxy/freq_ctr.h
src/freq_ctr.c