summaryrefslogtreecommitdiffstats
path: root/src/trex_watchdog.cpp
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-06-21 09:41:06 +0300
committerimarom <imarom@cisco.com>2016-06-21 09:41:06 +0300
commitb4a17c0d02d500a9a08a052b958160791279c023 (patch)
tree2d745d97db94cc46c32b85510aae8c2c3f182bba /src/trex_watchdog.cpp
parent0422016ab056245449e0e5bdf0dceef2c4f06e31 (diff)
WATCHDOG: reading the counter for the main loop is probably better with
a lock
Diffstat (limited to 'src/trex_watchdog.cpp')
-rw-r--r--src/trex_watchdog.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/trex_watchdog.cpp b/src/trex_watchdog.cpp
index c72ce69e..d099933b 100644
--- a/src/trex_watchdog.cpp
+++ b/src/trex_watchdog.cpp
@@ -225,8 +225,10 @@ void TrexWatchDog::_main() {
dsec_t now = now_sec();
- /* volatile are slow - read once per iteration */
+ /* to be on the safe side - read the count with a lock */
+ std::unique_lock<std::mutex> lock(m_lock);
int count = m_mon_count;
+ lock.unlock();
for (int i = 0; i < count; i++) {
TrexMonitor *monitor = m_monitors[i];