]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: clock: add clock_set_now_offset() helper
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 26 Jun 2025 17:21:36 +0000 (19:21 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Thu, 7 Aug 2025 20:27:05 +0000 (22:27 +0200)
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.

include/haproxy/clock.h
src/clock.c

index 664e53968980c11a1c3226c6338bf7e84632ec4e..3737fc51e0fa39d5946fe00643e133f7fe861e44 100644 (file)
@@ -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)
 {
index 16270aac332acf298afd8fd1678d7dba7e2b2bf1..6fba12a1c154e986008e2b491bf71a0b10e0ca55 100644 (file)
@@ -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.
  */