MINOR: time: move the time initialization out of tv_update_date()
authorWilly Tarreau <w@1wt.eu>
Sun, 11 Apr 2021 13:00:34 +0000 (15:00 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 11 Apr 2021 21:45:48 +0000 (23:45 +0200)
commitc4c80fb4eaf22b7aab6a9fd9d77f096a380f3e39
tree4bdb800af5ced3409fbdb770835d72cdb81ddb34
parent61c72c366e78a0e8fcc0d4d0d37b639eaff1abf9
MINOR: time: move the time initialization out of tv_update_date()

The time initialization was made a bit complex because we rely on a
dummy negative argument to reset all fields, leaving no distinction
between process-level initialization and thread-level initialization.
This patch changes this by introducing two functions, one for the
process and the second one for the threads. This removes ambigous
test and makes sure that the relevant fields are always initialized
exactly once. This also offers a better solution to the bug fixed in
commit b48e7c001 ("BUG/MEDIUM: time: make sure to always initialize
the global tick") as there is no more special values for global_now_ms.

It's simple enough to be backported if any other time-related issues
are encountered in stable versions in the future.
include/haproxy/time.h
src/haproxy.c
src/time.c