From 935de2a8ec8fce9f6b51cf10f7d4d1ed29625420 Mon Sep 17 00:00:00 2001 From: Yaroslav Brustinov Date: Sun, 5 Feb 2017 15:52:21 +0200 Subject: WatchDog and IO functions: ensure we return it to normal timeout in case of exceptions in the middle of function. Change-Id: I5d2e119f19c3e3214fdbe8108ea35af899ab49a5 Signed-off-by: Yaroslav Brustinov --- src/trex_watchdog.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/trex_watchdog.h') diff --git a/src/trex_watchdog.h b/src/trex_watchdog.h index 67dbb80d..b4512b6e 100644 --- a/src/trex_watchdog.h +++ b/src/trex_watchdog.h @@ -193,6 +193,8 @@ public: return instance; } + class IOFunction; + void init(bool enable); /** @@ -252,5 +254,30 @@ private: static bool g_signal_init; }; +class TrexWatchDog::IOFunction { +public: + static void io_begin() { + TrexMonitor * cur_monitor = TrexWatchDog::getInstance().get_current_monitor(); + if (cur_monitor != NULL) { + cur_monitor->io_begin(); + } + } + + static void io_end() { + TrexMonitor * cur_monitor = TrexWatchDog::getInstance().get_current_monitor(); + if (cur_monitor != NULL) { + cur_monitor->io_end(); + } + } + + IOFunction() { + IOFunction::io_begin(); + } + + ~IOFunction() { + IOFunction::io_end(); + } + +}; #endif /* __TREX_WATCHDOG_H__ */ -- cgit 1.2.3-korg