From: Aurelien DARRAGON Date: Thu, 7 Aug 2025 13:28:59 +0000 (+0200) Subject: MINOR: clock: add clock_get_now_offset() helper X-Git-Tag: v3.3-dev7~55 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c8282f61386ea6a5523a7da9343834a3d150cb1c;p=thirdparty%2Fhaproxy.git MINOR: clock: add clock_get_now_offset() helper Same as clock_set_now_offset() but to retrieve the offset from external location. --- diff --git a/include/haproxy/clock.h b/include/haproxy/clock.h index 3737fc51e..082ab1344 100644 --- a/include/haproxy/clock.h +++ b/include/haproxy/clock.h @@ -50,6 +50,7 @@ void clock_leaving_poll(int timeout, int interrupted); void clock_entering_poll(void); void clock_adjust_now_offset(void); void clock_set_now_offset(llong ofs); +llong clock_get_now_offset(void); static inline void clock_update_date(int max_wait, int interrupted) { diff --git a/src/clock.c b/src/clock.c index 6fba12a1c..6dbbd0ff9 100644 --- a/src/clock.c +++ b/src/clock.c @@ -369,6 +369,11 @@ void clock_set_now_offset(llong ofs) HA_ATOMIC_STORE(&now_offset, ofs); } +llong clock_get_now_offset(void) +{ + return HA_ATOMIC_LOAD(&now_offset); +} + /* must be called once per thread to initialize their thread-local variables. * Note that other threads might also be initializing and running in parallel. */