CLEANUP: time: use __tv_to_ms() in tv_update_date() instead of open-coding

Instead of calculating the current date in milliseconds by hand, let's
use __tv_to_ms() which was made exactly for this purpose.
This commit is contained in:
Willy Tarreau 2021-04-23 16:03:21 +02:00
parent 4d01f3dcdc
commit 1f9e11e7f0

View File

@ -236,7 +236,7 @@ void tv_update_date(int max_wait, int interrupted)
do {
tmp_now.tv_sec = (unsigned int)(old_now >> 32);
tmp_now.tv_usec = old_now & 0xFFFFFFFFU;
old_now_ms = tmp_now.tv_sec * 1000 + tmp_now.tv_usec / 1000;
old_now_ms = __tv_to_ms(&tmp_now);
if (__tv_islt(&now, &tmp_now))
now = tmp_now;
@ -245,7 +245,7 @@ void tv_update_date(int max_wait, int interrupted)
* equal to <global_now> or newer.
*/
new_now = ((ullong)now.tv_sec << 32) + (uint)now.tv_usec;
now_ms = now.tv_sec * 1000 + now.tv_usec / 1000;
now_ms = __tv_to_ms(&now);
if (tick_is_lt(now_ms, old_now_ms))
now_ms = old_now_ms;