From: Willy Tarreau Date: Sat, 10 Apr 2021 23:40:13 +0000 (+0200) Subject: CLEANUP: time: remove the now unused ms_left_scaled X-Git-Tag: v2.4-dev17~141 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=61c72c366e78a0e8fcc0d4d0d37b639eaff1abf9;p=thirdparty%2Fhaproxy.git CLEANUP: time: remove the now unused ms_left_scaled It was only used by freq_ctr and is not used anymore. In addition the local curr_sec_ms was removed, as well as the equivalent extern definitions which did not exist anymore either. --- diff --git a/include/haproxy/time.h b/include/haproxy/time.h index 93dd840800..f5c0da6926 100644 --- a/include/haproxy/time.h +++ b/include/haproxy/time.h @@ -49,9 +49,6 @@ #define MINTIME(old, new) (((new)<0)?(old):(((old)<0||(new)<(old))?(new):(old))) #define SETNOW(a) (*a=now) -extern THREAD_LOCAL unsigned int curr_sec_ms; /* millisecond of current second (0..999) */ -extern THREAD_LOCAL unsigned int ms_left_scaled; /* milliseconds left for current second (0..2^32-1) */ -extern THREAD_LOCAL unsigned int curr_sec_ms_scaled; /* millisecond of current second (0..2^32-1) */ extern THREAD_LOCAL unsigned int now_ms; /* internal date in milliseconds (may wrap) */ extern THREAD_LOCAL unsigned int samp_time; /* total elapsed time over current sample */ extern THREAD_LOCAL unsigned int idle_time; /* total idle time over current sample */ diff --git a/src/time.c b/src/time.c index fafe3720eb..9901dab103 100644 --- a/src/time.c +++ b/src/time.c @@ -18,7 +18,6 @@ #include #include -THREAD_LOCAL unsigned int ms_left_scaled; /* milliseconds left for current second (0..2^32-1) */ THREAD_LOCAL unsigned int now_ms; /* internal date in milliseconds (may wrap) */ THREAD_LOCAL unsigned int samp_time; /* total elapsed time over current sample */ THREAD_LOCAL unsigned int idle_time; /* total idle time over current sample */ @@ -178,7 +177,6 @@ int _tv_isgt(const struct timeval *tv1, const struct timeval *tv2) void tv_update_date(int max_wait, int interrupted) { struct timeval adjusted, deadline, tmp_now, tmp_adj; - unsigned int curr_sec_ms; /* millisecond of current second (0..999) */ unsigned int old_now_ms, new_now_ms; unsigned long long old_now; unsigned long long new_now; @@ -250,19 +248,7 @@ void tv_update_date(int max_wait, int interrupted) to_ms: now = adjusted; - curr_sec_ms = now.tv_usec / 1000; /* ms of current second */ - - /* For frequency counters, we'll need to know the ratio of the previous - * value to add to current value depending on the current millisecond. - * The principle is that during the first millisecond, we use 999/1000 - * of the past value and that during the last millisecond we use 0/1000 - * of the past value. In summary, we only use the past value during the - * first 999 ms of a second, and the last ms is used to complete the - * current measure. The value is scaled to (2^32-1) so that a simple - * multiply followed by a shift gives us the final value. - */ - ms_left_scaled = (999U - curr_sec_ms) * 4294967U; - now_ms = now.tv_sec * 1000 + curr_sec_ms; + now_ms = now.tv_sec * 1000 + now.tv_usec / 1000; /* update the global current millisecond */ old_now_ms = global_now_ms;