summaryrefslogtreecommitdiffstats
path: root/src/trex_watchdog.cpp
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-12-26 15:08:38 +0200
committerimarom <imarom@cisco.com>2016-12-26 15:09:06 +0200
commit9ad36b3da3d33cad1d0fbb629707515381260648 (patch)
tree89c237fadf7c383577827f17bffaf3760310023d /src/trex_watchdog.cpp
parentf14ca6aecb0b8236f474d6e7c1c19b9976dac7f4 (diff)
watchdog - support for long IO operations
also reduce complexity of the watchdog Signed-off-by: imarom <imarom@cisco.com>
Diffstat (limited to 'src/trex_watchdog.cpp')
-rw-r--r--src/trex_watchdog.cpp28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/trex_watchdog.cpp b/src/trex_watchdog.cpp
index f551a787..d2b6b803 100644
--- a/src/trex_watchdog.cpp
+++ b/src/trex_watchdog.cpp
@@ -126,12 +126,13 @@ static void _callstack_signal_handler(int signr, siginfo_t *info, void *secret)
*************************************/
void TrexMonitor::create(const std::string &name, double timeout_sec) {
- m_active_time_sec = now_sec();
m_tid = pthread_self();
m_name = name;
m_timeout_sec = timeout_sec;
+ m_base_timeout_sec = timeout_sec;
m_tickled = true;
m_ts = 0;
+ m_io_ref_cnt = 0;
/* the rare case of m_active_time_sec set out of order with tickled */
asm volatile("mfence" ::: "memory");
@@ -256,29 +257,26 @@ void TrexWatchDog::_main() {
for (int i = 0; i < count; i++) {
TrexMonitor *monitor = m_monitors[i];
- /* skip non active monitors */
- if (!monitor->is_active(now)) {
+ /* skip non expired monitors */
+ if (!monitor->is_expired(now)) {
continue;
}
-
- /* if its own - turn it off and write down the time */
+
+ /* it has expired but it was tickled */
if (monitor->is_tickled()) {
monitor->reset(now);
continue;
}
- /* if the monitor has expired - crash */
- if (monitor->is_expired(now)) {
- global_monitor = monitor;
-
- pthread_kill(monitor->get_tid(), SIGALRM);
+ /* crash */
+ global_monitor = monitor;
- /* nothing to do more... the other thread will terminate, but if not - we terminate */
- sleep(5);
- fprintf(stderr, "\n\n*** WATCHDOG violation detected on task '%s' which have failed to response to the signal ***\n\n", monitor->get_name().c_str());
- abort();
- }
+ pthread_kill(monitor->get_tid(), SIGALRM);
+ /* nothing to do more... the other thread will terminate, but if not - we terminate */
+ sleep(5);
+ fprintf(stderr, "\n\n*** WATCHDOG violation detected on task '%s' which have failed to response to the signal ***\n\n", monitor->get_name().c_str());
+ abort();
}
/* the internal clock - 250 ms */