From a56ae96bdbfe53894aad17192cd21d43c6e8a289 Mon Sep 17 00:00:00 2001 From: Yaroslav Brustinov Date: Sun, 1 Jan 2017 02:48:04 +0200 Subject: alter the watchdog timeout before push_remote and after, due to possible long io Change-Id: Ibddf830dbed8ee36c75113267645a576e38efa31 Signed-off-by: Yaroslav Brustinov --- src/rpc-server/commands/trex_rpc_cmd_general.cpp | 11 +++++++++++ src/stateless/dp/trex_stateless_dp_core.cpp | 12 ++++++++++++ src/trex_watchdog.cpp | 6 ++---- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/rpc-server/commands/trex_rpc_cmd_general.cpp b/src/rpc-server/commands/trex_rpc_cmd_general.cpp index d4854a79..82cbaca1 100644 --- a/src/rpc-server/commands/trex_rpc_cmd_general.cpp +++ b/src/rpc-server/commands/trex_rpc_cmd_general.cpp @@ -649,12 +649,23 @@ TrexRpcCmdPushRemote::_run(const Json::Value ¶ms, Json::Value &result) { } + /* IO might take time, increase timeout of WD */ + TrexMonitor * cur_monitor = TrexWatchDog::getInstance().get_current_monitor(); + if (cur_monitor != NULL) { + cur_monitor->io_begin(); + } + try { port->push_remote(pcap_filename, ipg_usec, min_ipg_sec, speedup, count, duration, is_dual); } catch (const TrexException &ex) { 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); diff --git a/src/stateless/dp/trex_stateless_dp_core.cpp b/src/stateless/dp/trex_stateless_dp_core.cpp index ed130c29..0a317170 100644 --- a/src/stateless/dp/trex_stateless_dp_core.cpp +++ b/src/stateless/dp/trex_stateless_dp_core.cpp @@ -1281,6 +1281,12 @@ bool CGenNodePCAP::create(uint8_t port_id, m_dir = dir; 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(); + } + /* mark this node as slow path */ set_slow_path(true); @@ -1344,6 +1350,12 @@ void CGenNodePCAP::destroy() { m_reader = NULL; } + /* end of io, return normal timeout of WD */ + TrexMonitor * cur_monitor = TrexWatchDog::getInstance().get_current_monitor(); + if (cur_monitor != NULL) { + cur_monitor->io_end(); + } + m_state = PCAP_INVALID; } diff --git a/src/trex_watchdog.cpp b/src/trex_watchdog.cpp index d2b6b803..8a06746b 100644 --- a/src/trex_watchdog.cpp +++ b/src/trex_watchdog.cpp @@ -155,16 +155,14 @@ void TrexWatchDog::init(bool enable){ * */ 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 m_monitors[i]; } } - return cur_monitor; + return NULL; } -- cgit 1.2.3-korg