summaryrefslogtreecommitdiffstats
path: root/src/stateless/cp/trex_stateless.cpp
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/cp/trex_stateless.cpp
parenta5cc1c90587d859d5f1e7f6d9ee49024cd2e9481 (diff)
support for graceful shutdown
Diffstat (limited to 'src/stateless/cp/trex_stateless.cpp')
-rw-r--r--src/stateless/cp/trex_stateless.cpp32
1 files changed, 26 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