diff options
author | henrika@webrtc.org <henrika@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d> | 2013-04-05 14:34:57 +0000 |
---|---|---|
committer | henrika@webrtc.org <henrika@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d> | 2013-04-05 14:34:57 +0000 |
commit | 1d25eacc9444fecc13c8b2ada929b531841df730 (patch) | |
tree | 7e9ce233f2d3c4bdfcd093b29981aa925046d130 /system_wrappers/source/trace_posix.cc | |
parent | 004f46271b8a6e18464917a9300599454389861a (diff) | |
download | webrtc-1d25eacc9444fecc13c8b2ada929b531841df730.tar.gz |
Resolves TSan v2 reports data races in voe_auto_test.
--- Note that I will add more fixes to this CL ---
BUG=1590
Review URL: https://webrtc-codereview.appspot.com/1286005
git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@3770 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'system_wrappers/source/trace_posix.cc')
-rw-r--r-- | system_wrappers/source/trace_posix.cc | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/system_wrappers/source/trace_posix.cc b/system_wrappers/source/trace_posix.cc index 49659690..d0ab45b7 100644 --- a/system_wrappers/source/trace_posix.cc +++ b/system_wrappers/source/trace_posix.cc @@ -38,13 +38,15 @@ namespace webrtc { -TracePosix::TracePosix() { +TracePosix::TracePosix() + : crit_sect_(*CriticalSectionWrapper::CreateCriticalSection()) { struct timeval system_time_high_res; gettimeofday(&system_time_high_res, 0); prev_api_tick_count_ = prev_tick_count_ = system_time_high_res.tv_sec; } TracePosix::~TracePosix() { + delete &crit_sect_; StopThread(); } @@ -60,13 +62,17 @@ WebRtc_Word32 TracePosix::AddTime(char* trace_message, const WebRtc_UWord32 ms_time = system_time_high_res.tv_usec / 1000; WebRtc_UWord32 prev_tickCount = 0; - if (level == kTraceApiCall) { - prev_tickCount = prev_tick_count_; - prev_tick_count_ = ms_time; - } else { - prev_tickCount = prev_api_tick_count_; - prev_api_tick_count_ = ms_time; + { + CriticalSectionScoped lock(&crit_sect_); + if (level == kTraceApiCall) { + prev_tickCount = prev_tick_count_; + prev_tick_count_ = ms_time; + } else { + prev_tickCount = prev_api_tick_count_; + prev_api_tick_count_ = ms_time; + } } + WebRtc_UWord32 dw_delta_time = ms_time - prev_tickCount; if (prev_tickCount == 0) { dw_delta_time = 0; |