diff --git a/include/haproxy/freq_ctr.h b/include/haproxy/freq_ctr.h index d5cea414ef..b1db43ef66 100644 --- a/include/haproxy/freq_ctr.h +++ b/include/haproxy/freq_ctr.h @@ -88,7 +88,7 @@ static inline unsigned int update_freq_ctr_period(struct freq_ctr_period *ctr, curr_tick = ctr->curr_tick; do { - now_ms_tmp = (uint32_t)global_now / 1000; + now_ms_tmp = global_now_ms; if (now_ms_tmp - curr_tick < period) return _HA_ATOMIC_ADD(&ctr->curr_ctr, inc); diff --git a/src/freq_ctr.c b/src/freq_ctr.c index 8fd0c90f09..42fbc1cea6 100644 --- a/src/freq_ctr.c +++ b/src/freq_ctr.c @@ -206,7 +206,7 @@ unsigned int read_freq_ctr_period(struct freq_ctr_period *ctr, unsigned int peri break; }; - remain = curr_tick + period - (uint32_t)global_now / 1000; + remain = curr_tick + period - global_now_ms; if (unlikely((int)remain < 0)) { /* We're past the first period, check if we can still report a * part of last period or if we're too far away. @@ -253,7 +253,7 @@ unsigned int freq_ctr_remain_period(struct freq_ctr_period *ctr, unsigned int pe break; }; - remain = curr_tick + period - (uint32_t)global_now / 1000; + remain = curr_tick + period - global_now_ms; if (likely((int)remain < 0)) { /* We're past the first period, check if we can still report a * part of last period or if we're too far away.