uint64_t now_cpu_time_thread(const struct thread_info *thr);
uint64_t now_mono_time(void);
uint64_t now_cpu_time(void);
+void clock_set_local_source(void);
void clock_update_date(int max_wait, int interrupted);
void clock_init_process_date(void);
void clock_init_thread_date(void);
#include <sys/time.h>
#include <time.h>
+#ifdef USE_THREAD
+#include <pthread.h>
+#endif
+
#include <haproxy/api.h>
#include <haproxy/activity.h>
#include <haproxy/clock.h>
return ret;
}
+/* set the clock source for the local thread */
+void clock_set_local_source(void)
+{
+#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0) && defined(_POSIX_THREAD_CPUTIME)
+#ifdef USE_THREAD
+ pthread_getcpuclockid(pthread_self(), &ti->clock_id);
+#else
+ ti->clock_id = CLOCK_THREAD_CPUTIME_ID;
+#endif
+#endif
+}
+
/* clock_update_date: sets <date> to system time, and sets <now> to something as
* close as possible to real time, following a monotonic function. The main
* principle consists in detecting backwards and forwards time jumps and adjust
ha_set_tid((unsigned long)data);
set_thread_cpu_affinity();
sched = &task_per_thread[tid];
+ clock_set_local_source();
-#if (_POSIX_TIMERS > 0) && defined(_POSIX_THREAD_CPUTIME)
-#ifdef USE_THREAD
- pthread_getcpuclockid(pthread_self(), &ti->clock_id);
-#else
- ti->clock_id = CLOCK_THREAD_CPUTIME_ID;
-#endif
-#endif
/* Now, initialize one thread init at a time. This is better since
* some init code is a bit tricky and may release global resources
* after reallocating them locally. This will also ensure there is