From ac5294a6a46318a5954a22458e332760a94620f1 Mon Sep 17 00:00:00 2001 From: Masaori Koshiba Date: Tue, 1 Nov 2022 09:12:39 +0900 Subject: [PATCH] TSan: Fix data race of updating current time --- iocore/eventsystem/I_Thread.h | 4 +++- iocore/eventsystem/Thread.cc | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/iocore/eventsystem/I_Thread.h b/iocore/eventsystem/I_Thread.h index 844cfaeb01f..76d5cabd867 100644 --- a/iocore/eventsystem/I_Thread.h +++ b/iocore/eventsystem/I_Thread.h @@ -68,6 +68,8 @@ #include "tscore/ink_thread.h" #include "I_ProxyAllocator.h" +#include + class ProxyMutex; constexpr int MAX_THREAD_NAME_LENGTH = 16; @@ -177,7 +179,7 @@ class Thread protected: Thread(); - static ink_hrtime cur_time; + static std::atomic cur_time; }; extern Thread *this_thread(); diff --git a/iocore/eventsystem/Thread.cc b/iocore/eventsystem/Thread.cc index 38c6c340908..11db72acda3 100644 --- a/iocore/eventsystem/Thread.cc +++ b/iocore/eventsystem/Thread.cc @@ -34,7 +34,7 @@ // Common Interface impl // /////////////////////////////////////////////// -ink_hrtime Thread::cur_time = ink_get_hrtime_internal(); +std::atomic Thread::cur_time = ink_get_hrtime_internal(); thread_local Thread *Thread::this_thread_ptr; Thread::Thread()