summaryrefslogtreecommitdiffstats
path: root/src/stateless
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-07-27 11:08:09 +0300
committerimarom <imarom@cisco.com>2016-07-27 16:01:13 +0300
commit344e3045d8346b4b204692e591e1556fc2333f97 (patch)
treec2a668f406c7f38136a2bb513ccf7dde765cfc3f /src/stateless
parenta5cc1c90587d859d5f1e7f6d9ee49024cd2e9481 (diff)
support for graceful shutdown
Diffstat (limited to 'src/stateless')
-rw-r--r--src/stateless/cp/trex_stateless.cpp32
-rw-r--r--src/stateless/cp/trex_stateless.h6
2 files changed, 32 insertions, 6 deletions
diff --git a/src/stateless/cp/trex_stateless.cpp b/src/stateless/cp/trex_stateless.cpp
index 8633897e..6d80539c 100644
--- a/src/stateless/cp/trex_stateless.cpp
+++ b/src/stateless/cp/trex_stateless.cpp
@@ -68,6 +68,8 @@ TrexStateless::TrexStateless(const TrexStatelessCfg &cfg) {
*/
TrexStateless::~TrexStateless() {
+ shutdown();
+
/* release memory for ports */
for (auto port : m_ports) {
delete port;
@@ -75,15 +77,33 @@ TrexStateless::~TrexStateless() {
m_ports.clear();
/* stops the RPC server */
- m_rpc_server->stop();
- delete m_rpc_server;
-
- m_rpc_server = NULL;
+ if (m_rpc_server) {
+ delete m_rpc_server;
+ m_rpc_server = NULL;
+ }
- delete m_platform_api;
- m_platform_api = NULL;
+ if (m_platform_api) {
+ delete m_platform_api;
+ m_platform_api = NULL;
+ }
}
+/**
+* shutdown the server
+*/
+void TrexStateless::shutdown() {
+
+ /* stop ports */
+ for (TrexStatelessPort *port : m_ports) {
+ /* safe to call stop even if not active */
+ port->stop_traffic();
+ }
+
+ /* shutdown the RPC server */
+ if (m_rpc_server) {
+ m_rpc_server->stop();
+ }
+}
/**
* starts the control plane side
diff --git a/src/stateless/cp/trex_stateless.h b/src/stateless/cp/trex_stateless.h
index 83ab6976..7ea669df 100644
--- a/src/stateless/cp/trex_stateless.h
+++ b/src/stateless/cp/trex_stateless.h
@@ -132,6 +132,11 @@ public:
/**
+ * shutdown the server
+ */
+ void shutdown();
+
+ /**
* fetch all the stats
*
*/
@@ -188,6 +193,7 @@ protected:
/* API */
APIClass m_api_classes[APIClass::API_CLASS_TYPE_MAX];
+
};
/**