}
- /* IO might take time, increase timeout of WD */
- TrexMonitor * cur_monitor = TrexWatchDog::getInstance().get_current_monitor();
- if (cur_monitor != NULL) {
- cur_monitor->io_begin();
- }
+ /* IO might take time, increase timeout of WD inside this function */
+ TrexWatchDog::IOFunction dummy;
+ (void)dummy;
try {
port->push_remote(pcap_filename, ipg_usec, min_ipg_sec, speedup, count, duration, is_dual);
generate_execute_err(result, ex.what());
}
- /* revert timeout of WD */
- if (cur_monitor != NULL) {
- cur_monitor->io_end();
- }
-
result["result"] = Json::objectValue;
return (TREX_RPC_CMD_OK);
m_min_ipg_sec = min_ipg_sec;
/* increase timeout of WD due to io */
- TrexMonitor * cur_monitor = TrexWatchDog::getInstance().get_current_monitor();
- if (cur_monitor != NULL) {
- cur_monitor->io_begin();
- }
+ TrexWatchDog::IOFunction::io_begin();
/* mark this node as slow path */
set_slow_path(true);
}
/* end of io, return normal timeout of WD */
- TrexMonitor * cur_monitor = TrexWatchDog::getInstance().get_current_monitor();
- if (cur_monitor != NULL) {
- cur_monitor->io_end();
- }
+ TrexWatchDog::IOFunction::io_end();
m_state = PCAP_INVALID;
}
return instance;
}
+ class IOFunction;
+
void init(bool enable);
/**
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__ */