summaryrefslogtreecommitdiffstats
path: root/src/trex_watchdog.cpp
diff options
context:
space:
mode:
authorYaroslav Brustinov <ybrustin@cisco.com>2016-12-25 15:30:38 +0200
committerYaroslav Brustinov <ybrustin@cisco.com>2016-12-25 15:30:38 +0200
commitf5350dfb9a746c9c70e2b7dcc879ac474ac6d3e0 (patch)
treea56559bfbff686ebb5c261521df66a6357f1d70a /src/trex_watchdog.cpp
parent7c25e2016ae0ce0991f21bc1e4c60d071db3e452 (diff)
Disable watchdog for 5 seconds at Mellanox link up/down command
Change-Id: If19c9c0d3e5d684e6157ab5c71a927e2e89b8211 Signed-off-by: Yaroslav Brustinov <ybrustin@cisco.com>
Diffstat (limited to 'src/trex_watchdog.cpp')
-rw-r--r--src/trex_watchdog.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/trex_watchdog.cpp b/src/trex_watchdog.cpp
index d2bbeafa..f551a787 100644
--- a/src/trex_watchdog.cpp
+++ b/src/trex_watchdog.cpp
@@ -149,6 +149,25 @@ void TrexWatchDog::init(bool enable){
}
/**
+ * get pointer to monitor of current thread
+ * (NULL if no monitor)
+ *
+ */
+TrexMonitor * TrexWatchDog::get_current_monitor() {
+ TrexMonitor * cur_monitor = NULL;
+
+ for (int i = 0; i < m_mon_count; i++) {
+ if ( m_monitors[i]->get_tid() == pthread_self() ) {
+ cur_monitor = m_monitors[i];
+ break;
+ }
+ }
+
+ return cur_monitor;
+}
+
+
+/**
* register a monitor
* this function is thread safe
*
@@ -162,12 +181,11 @@ void TrexWatchDog::register_monitor(TrexMonitor *monitor) {
std::unique_lock<std::mutex> lock(m_lock);
/* sanity - not a must but why not... */
- for (int i = 0; i < m_mon_count; i++) {
- if ( (monitor == m_monitors[i]) || (m_monitors[i]->get_tid() == pthread_self()) ) {
- std::stringstream ss;
- ss << "WATCHDOG: double register detected\n\n" << Backtrace();
- throw TrexException(ss.str());
- }
+ TrexMonitor * cur_monitor = get_current_monitor();
+ if ( cur_monitor != NULL || cur_monitor == monitor ) {
+ std::stringstream ss;
+ ss << "WATCHDOG: double register detected\n\n" << Backtrace();
+ throw TrexException(ss.str());
}
/* check capacity */