This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 9.2.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/9.2.x by this push:
     new 371ff9a288 TSan: Make Thread::cur_time thread local (#9184)
371ff9a288 is described below

commit 371ff9a2882e41b31cadb569a37fb4603a929874
Author: Masaori Koshiba <[email protected]>
AuthorDate: Tue Feb 14 09:52:33 2023 +0900

    TSan: Make Thread::cur_time thread local (#9184)
    
    (cherry picked from commit 72e660233155b8c825bc215324c6fbd9e2197c97)
---
 iocore/eventsystem/I_Thread.h | 6 +++---
 iocore/eventsystem/Thread.cc  | 2 +-
 proxy/logging/Log.cc          | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/iocore/eventsystem/I_Thread.h b/iocore/eventsystem/I_Thread.h
index 844cfaeb01..25ff8982e9 100644
--- a/iocore/eventsystem/I_Thread.h
+++ b/iocore/eventsystem/I_Thread.h
@@ -156,8 +156,8 @@ public:
       This gets a cached copy of the time so it is very fast and reasonably 
accurate.
       The cached time is updated every time the actual operating system time 
is fetched which is
       at least every 10ms and generally more frequently.
-      @note The cached copy shared among threads which means the cached copy 
is updated
-      for all threads if any thread updates it.
+
+      @note The cached copy is thread local which means each thread need to 
update the cached copy by itself.
   */
   static ink_hrtime get_hrtime();
 
@@ -177,7 +177,7 @@ public:
 protected:
   Thread();
 
-  static ink_hrtime cur_time;
+  static thread_local ink_hrtime cur_time;
 };
 
 extern Thread *this_thread();
diff --git a/iocore/eventsystem/Thread.cc b/iocore/eventsystem/Thread.cc
index 38c6c34090..5bdc5fc765 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();
+thread_local ink_hrtime Thread::cur_time = ink_get_hrtime_internal();
 thread_local Thread *Thread::this_thread_ptr;
 
 Thread::Thread()
diff --git a/proxy/logging/Log.cc b/proxy/logging/Log.cc
index 56530c79df..281247f76a 100644
--- a/proxy/logging/Log.cc
+++ b/proxy/logging/Log.cc
@@ -1433,7 +1433,7 @@ Log::flush_thread_main(void * /* args ATS_UNUSED */)
 
     // Time to work on periodic events??
     //
-    now = Thread::get_hrtime() / HRTIME_SECOND;
+    now = Thread::get_hrtime_updated() / HRTIME_SECOND;
     if (now >= last_time + periodic_tasks_interval) {
       Debug("log-preproc", "periodic tasks for %" PRId64, (int64_t)now);
       periodic_tasks(now);

Reply via email to