From: Aurelien DARRAGON Date: Thu, 26 Jun 2025 17:21:36 +0000 (+0200) Subject: MINOR: clock: add clock_set_now_offset() helper X-Git-Tag: v3.3-dev7~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=20f9d8fa4e132478044e2188706e14d56c758e82;p=thirdparty%2Fhaproxy.git MINOR: clock: add clock_set_now_offset() helper Since now_offset is a static variable and is not exposed outside from clock.c, let's add an helper so that it becomes possible to set its value from another source file. --- diff --git a/include/haproxy/clock.h b/include/haproxy/clock.h index 664e53968..3737fc51e 100644 --- a/include/haproxy/clock.h +++ b/include/haproxy/clock.h @@ -49,6 +49,7 @@ uint clock_report_idle(void); 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); static inline void clock_update_date(int max_wait, int interrupted) { diff --git a/src/clock.c b/src/clock.c index 16270aac3..6fba12a1c 100644 --- a/src/clock.c +++ b/src/clock.c @@ -364,6 +364,11 @@ void clock_adjust_now_offset(void) HA_ATOMIC_STORE(&now_offset, now_ns - tv_to_ns(&date)); } +void clock_set_now_offset(llong ofs) +{ + HA_ATOMIC_STORE(&now_offset, ofs); +} + /* must be called once per thread to initialize their thread-local variables. * Note that other threads might also be initializing and running in parallel. */