alter the watchdog timeout before push_remote and after, due to possible long io 39/5339/1
authorYaroslav Brustinov <[email protected]>
Sun, 1 Jan 2017 00:48:04 +0000 (02:48 +0200)
committerYaroslav Brustinov <[email protected]>
Sun, 1 Jan 2017 00:48:04 +0000 (02:48 +0200)
Change-Id: Ibddf830dbed8ee36c75113267645a576e38efa31
Signed-off-by: Yaroslav Brustinov <[email protected]>
src/rpc-server/commands/trex_rpc_cmd_general.cpp
src/stateless/dp/trex_stateless_dp_core.cpp
src/trex_watchdog.cpp

index d4854a7..82cbaca 100644 (file)
@@ -649,12 +649,23 @@ TrexRpcCmdPushRemote::_run(const Json::Value &params, 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);
 
index ed130c2..0a31717 100644 (file)
@@ -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;
 }
 
index d2b6b80..8a06746 100644 (file)
@@ -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;
 }