From: Christopher Faulet Date: Fri, 1 Sep 2017 10:18:36 +0000 (+0200) Subject: MINOR: freq_ctr: Return the new value after an update X-Git-Tag: v1.8-dev3~119 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de2075fd2186ccf0563163e1b4295ff152860c3f;p=thirdparty%2Fhaproxy.git MINOR: freq_ctr: Return the new value after an update This will ease threads support integration. --- diff --git a/include/proto/freq_ctr.h b/include/proto/freq_ctr.h index 70b295e8a9..0d0411041a 100644 --- a/include/proto/freq_ctr.h +++ b/include/proto/freq_ctr.h @@ -45,14 +45,15 @@ static inline void rotate_freq_ctr(struct freq_ctr *ctr) * rotated if the period is over. It is important that it correctly initializes * a null area. */ -static inline void update_freq_ctr(struct freq_ctr *ctr, unsigned int inc) +static inline unsigned int update_freq_ctr(struct freq_ctr *ctr, unsigned int inc) { if (likely(ctr->curr_sec == now.tv_sec)) { ctr->curr_ctr += inc; - return; + return ctr->curr_ctr; } rotate_freq_ctr(ctr); ctr->curr_ctr = inc; + return ctr->curr_ctr; /* Note: later we may want to propagate the update to other counters */ } @@ -79,15 +80,16 @@ static inline void rotate_freq_ctr_period(struct freq_ctr_period *ctr, * a null area. This one works on frequency counters which have a period * different from one second. */ -static inline void update_freq_ctr_period(struct freq_ctr_period *ctr, - unsigned int period, unsigned int inc) +static inline unsigned int update_freq_ctr_period(struct freq_ctr_period *ctr, + unsigned int period, unsigned int inc) { if (likely(now_ms - ctr->curr_tick < period)) { ctr->curr_ctr += inc; - return; + return ctr->curr_ctr; } rotate_freq_ctr_period(ctr, period); ctr->curr_ctr = inc; + return ctr->curr_ctr; /* Note: later we may want to propagate the update to other counters */ }