From 509b68a5cff9503ffffe2e72a2812bb10ca0380f Mon Sep 17 00:00:00 2001 From: imarom Date: Sun, 16 Aug 2015 18:06:30 +0300 Subject: draft --- src/gtest/rpc_test.cpp | 83 +++++++++++++++++- src/rpc-server/include/trex_rpc_cmd_api.h | 75 ++++++++++++++++ src/rpc-server/include/trex_rpc_cmds_table.h | 65 ++++++++++++++ src/rpc-server/include/trex_rpc_commands.h | 101 ---------------------- src/rpc-server/include/trex_rpc_jsonrpc_v2.h | 1 + src/rpc-server/src/commands/trex_rpc_cmd_test.cpp | 84 ++++++++++++++++++ src/rpc-server/src/commands/trex_rpc_cmds.h | 46 ++++++++++ src/rpc-server/src/trex_rpc_cmds_table.cpp | 50 +++++++++++ src/rpc-server/src/trex_rpc_commands.cpp | 87 ------------------- src/rpc-server/src/trex_rpc_jsonrpc_v2.cpp | 13 +-- src/rpc-server/src/trex_rpc_req_resp.cpp | 1 + src/rpc-server/src/trex_rpc_server.cpp | 1 + 12 files changed, 409 insertions(+), 198 deletions(-) create mode 100644 src/rpc-server/include/trex_rpc_cmd_api.h create mode 100644 src/rpc-server/include/trex_rpc_cmds_table.h delete mode 100644 src/rpc-server/include/trex_rpc_commands.h create mode 100644 src/rpc-server/src/commands/trex_rpc_cmd_test.cpp create mode 100644 src/rpc-server/src/commands/trex_rpc_cmds.h create mode 100644 src/rpc-server/src/trex_rpc_cmds_table.cpp delete mode 100644 src/rpc-server/src/trex_rpc_commands.cpp (limited to 'src') diff --git a/src/gtest/rpc_test.cpp b/src/gtest/rpc_test.cpp index d8fc5389..0141dec4 100644 --- a/src/gtest/rpc_test.cpp +++ b/src/gtest/rpc_test.cpp @@ -105,6 +105,71 @@ TEST_F(RpcTest, basic_rpc_test) { EXPECT_EQ(response["jsonrpc"], "2.0"); EXPECT_EQ(response["id"], 482); EXPECT_EQ(response["error"]["code"], -32601); + + /* error but as notification */ + req_str = "{\"jsonrpc\": \"2.0\", \"method\": \"jfgldjlfds\"}"; + resp_str = send_msg(req_str); + + EXPECT_TRUE(reader.parse(resp_str, response, false)); + EXPECT_TRUE(response == Json::Value::null); + + +} + +TEST_F(RpcTest, test_add_command) { + Json::Value request; + Json::Value response; + Json::Reader reader; + + string req_str; + string resp_str; + + /* simple add - missing paramters */ + req_str = "{\"jsonrpc\": \"2.0\", \"method\": \"test_rpc_add\", \"id\": 488}"; + resp_str = send_msg(req_str); + + EXPECT_TRUE(reader.parse(resp_str, response, false)); + EXPECT_EQ(response["jsonrpc"], "2.0"); + EXPECT_EQ(response["id"], 488); + EXPECT_EQ(response["error"]["code"], -32602); + + /* simple add that works */ + req_str = "{\"jsonrpc\": \"2.0\", \"method\": \"test_rpc_add\", \"params\": {\"x\": 17, \"y\": -13} , \"id\": \"itay\"}"; + resp_str = send_msg(req_str); + + EXPECT_TRUE(reader.parse(resp_str, response, false)); + EXPECT_EQ(response["jsonrpc"], "2.0"); + EXPECT_EQ(response["id"], "itay"); + EXPECT_EQ(response["result"], 4); + + /* add with bad paratemers types */ + req_str = "{\"jsonrpc\": \"2.0\", \"method\": \"test_rpc_add\", \"params\": {\"x\": \"blah\", \"y\": -13} , \"id\": 17}"; + resp_str = send_msg(req_str); + + EXPECT_TRUE(reader.parse(resp_str, response, false)); + EXPECT_EQ(response["jsonrpc"], "2.0"); + EXPECT_EQ(response["id"], 17); + EXPECT_EQ(response["error"]["code"], -32602); + + /* add with invalid count of parameters */ + req_str = "{\"jsonrpc\": \"2.0\", \"method\": \"test_rpc_add\", \"params\": {\"y\": -13} , \"id\": 17}"; + resp_str = send_msg(req_str); + + EXPECT_TRUE(reader.parse(resp_str, response, false)); + EXPECT_EQ(response["jsonrpc"], "2.0"); + EXPECT_EQ(response["id"], 17); + EXPECT_EQ(response["error"]["code"], -32602); + + + /* big numbers */ + req_str = "{\"jsonrpc\": \"2.0\", \"method\": \"test_rpc_add\", \"params\": {\"x\": 4827371, \"y\": -39181273} , \"id\": \"itay\"}"; + resp_str = send_msg(req_str); + + EXPECT_TRUE(reader.parse(resp_str, response, false)); + EXPECT_EQ(response["jsonrpc"], "2.0"); + EXPECT_EQ(response["id"], "itay"); + EXPECT_EQ(response["result"], -34353902); + } TEST_F(RpcTest, batch_rpc_test) { @@ -116,26 +181,36 @@ TEST_F(RpcTest, batch_rpc_test) { string resp_str; req_str = "[ \ - {\"jsonrpc\": \"2.0\", \"method\": \"sum\", \"params\": [1,2,4], \"id\": \"1\"}, \ - {\"jsonrpc\": \"2.0\", \"method\": \"notify_hello\", \"params\": [7]}, \ - {\"jsonrpc\": \"2.0\", \"method\": \"subtract\", \"params\": [42,23], \"id\": \"2\"}, \ + {\"jsonrpc\": \"2.0\", \"method\": \"test_rpc_add\", \"params\": {\"x\": 22, \"y\": 17}, \"id\": \"1\"}, \ + {\"jsonrpc\": \"2.0\", \"method\": \"test_rpc_sub\", \"params\": {\"x\": 22, \"y\": 17}, \"id\": \"2\"}, \ + {\"jsonrpc\": \"2.0\", \"method\": \"test_rpc_add\", \"params\": {\"x\": 22, \"y\": \"itay\"}, \"id\": \"2\"}, \ {\"foo\": \"boo\"}, \ {\"jsonrpc\": \"2.0\", \"method\": \"foo.get\", \"params\": {\"name\": \"myself\"}, \"id\": \"5\"}, \ {\"jsonrpc\": \"2.0\", \"method\": \"get_data\", \"id\": \"9\"} \ ]"; resp_str = send_msg(req_str); - cout << resp_str; + EXPECT_TRUE(reader.parse(resp_str, response, false)); EXPECT_TRUE(response.isArray()); // message 1 EXPECT_TRUE(response[0]["jsonrpc"] == "2.0"); EXPECT_TRUE(response[0]["id"] == "1"); + EXPECT_TRUE(response[0]["result"] == 39); // message 2 EXPECT_TRUE(response[1]["jsonrpc"] == "2.0"); EXPECT_TRUE(response[1]["id"] == "2"); + EXPECT_TRUE(response[1]["result"] == 5); + + // message 3 + EXPECT_TRUE(response[2]["jsonrpc"] == "2.0"); + EXPECT_TRUE(response[2]["id"] == "2"); + EXPECT_TRUE(response[2]["error"]["code"] == -32602); + + // message 4 + EXPECT_TRUE(response[3] == Json::Value::null); return; } diff --git a/src/rpc-server/include/trex_rpc_cmd_api.h b/src/rpc-server/include/trex_rpc_cmd_api.h new file mode 100644 index 00000000..c0416104 --- /dev/null +++ b/src/rpc-server/include/trex_rpc_cmd_api.h @@ -0,0 +1,75 @@ +/* + Itay Marom + Cisco Systems, Inc. +*/ + +/* +Copyright (c) 2015-2015 Cisco Systems, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef __TREX_RPC_CMD_API_H__ +#define __TREX_RPC_CMD_API_H__ + +#include +#include +#include + +/** + * interface for RPC command + * + * @author imarom (13-Aug-15) + */ +class TrexRpcCommand { +public: + + /** + * describe different types of rc for run() + */ + enum rpc_cmd_rc_e { + RPC_CMD_OK, + RPC_CMD_PARAM_COUNT_ERR = 1, + RPC_CMD_PARAM_PARSE_ERR + }; + + /** + * method name and params + */ + TrexRpcCommand(const std::string &method_name) : m_name(method_name) { + + } + + rpc_cmd_rc_e run(const Json::Value ¶ms, Json::Value &result) { + return _run(params, result); + } + + const std::string &get_name() { + return m_name; + } + + virtual ~TrexRpcCommand() {} + +protected: + + /** + * implemented by the dervied class + * + */ + virtual rpc_cmd_rc_e _run(const Json::Value ¶ms, Json::Value &result) = 0; + + std::string m_name; +}; + +#endif /* __TREX_RPC_CMD_API_H__ */ + diff --git a/src/rpc-server/include/trex_rpc_cmds_table.h b/src/rpc-server/include/trex_rpc_cmds_table.h new file mode 100644 index 00000000..3cf67669 --- /dev/null +++ b/src/rpc-server/include/trex_rpc_cmds_table.h @@ -0,0 +1,65 @@ +/* + Itay Marom + Cisco Systems, Inc. +*/ + +/* +Copyright (c) 2015-2015 Cisco Systems, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef __TREX_RPC_CMDS_TABLE_H__ +#define __TREX_RPC_CMDS_TABLE_H__ + +#include +#include +#include +#include + +class TrexRpcCommand; + +/** + * holds all the commands registered + * + * @author imarom (13-Aug-15) + */ +class TrexRpcCommandsTable { + +public: + + static TrexRpcCommandsTable& get_instance() { + static TrexRpcCommandsTable instance; + return instance; + } + + void register_command(TrexRpcCommand *command); + + TrexRpcCommand * lookup(const std::string &method_name); + +private: + TrexRpcCommandsTable(); + ~TrexRpcCommandsTable(); + + /* c++ 2011 style singleton */ + TrexRpcCommandsTable(TrexRpcCommandsTable const&) = delete; + void operator=(TrexRpcCommandsTable const&) = delete; + + /** + * holds all the registered RPC commands + * + */ + std::unordered_map m_rpc_cmd_table; +}; + +#endif /* __TREX_RPC_CMDS_TABLE_H__ */ diff --git a/src/rpc-server/include/trex_rpc_commands.h b/src/rpc-server/include/trex_rpc_commands.h deleted file mode 100644 index ef9f5eaa..00000000 --- a/src/rpc-server/include/trex_rpc_commands.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - Itay Marom - Cisco Systems, Inc. -*/ - -/* -Copyright (c) 2015-2015 Cisco Systems, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -#ifndef __TREX_RPC_COMMANDS_H__ -#define __TREX_RPC_COMMANDS_H__ - -#include -#include -#include -#include - -/** - * interface for RPC command - * - * @author imarom (13-Aug-15) - */ -class TrexRpcCommand { -public: - - /** - * describe different types of rc for run() - */ - enum rpc_cmd_rc_e { - RPC_CMD_OK, - RPC_CMD_PARAM_COUNT_ERR = 1, - RPC_CMD_PARAM_PARSE_ERR - }; - - /** - * method name and params - */ - TrexRpcCommand(const std::string &method_name); - - rpc_cmd_rc_e run(const Json::Value ¶ms, std::string &output); - - const std::string &get_name(); - - virtual ~TrexRpcCommand() {} - -protected: - - /** - * implemented by the dervied class - * - */ - virtual rpc_cmd_rc_e _run(const Json::Value ¶ms, std::string &output) = 0; - - std::string m_name; -}; - -/** - * holds all the commands registered - * - * @author imarom (13-Aug-15) - */ -class TrexRpcCommandsTable { - -public: - - static TrexRpcCommandsTable& get_instance() { - static TrexRpcCommandsTable instance; - return instance; - } - - void register_command(TrexRpcCommand *command); - - TrexRpcCommand * lookup(const std::string &method_name); - -private: - TrexRpcCommandsTable(); - - /* c++ 2011 style singleton */ - TrexRpcCommandsTable(TrexRpcCommandsTable const&) = delete; - void operator=(TrexRpcCommandsTable const&) = delete; - - /** - * holds all the registered RPC commands - * - */ - std::unordered_map m_rpc_cmd_table; -}; - -#endif /* __TREX_RPC_COMMANDS_H__ */ diff --git a/src/rpc-server/include/trex_rpc_jsonrpc_v2.h b/src/rpc-server/include/trex_rpc_jsonrpc_v2.h index 963dab7b..a9b6faa3 100644 --- a/src/rpc-server/include/trex_rpc_jsonrpc_v2.h +++ b/src/rpc-server/include/trex_rpc_jsonrpc_v2.h @@ -37,6 +37,7 @@ class TrexJsonRpcV2ParsedObject { public: TrexJsonRpcV2ParsedObject(const Json::Value &msg_id, bool force); + virtual ~TrexJsonRpcV2ParsedObject() {} /** * main function to execute the command diff --git a/src/rpc-server/src/commands/trex_rpc_cmd_test.cpp b/src/rpc-server/src/commands/trex_rpc_cmd_test.cpp new file mode 100644 index 00000000..913736af --- /dev/null +++ b/src/rpc-server/src/commands/trex_rpc_cmd_test.cpp @@ -0,0 +1,84 @@ +/* + Itay Marom + Cisco Systems, Inc. +*/ + +/* +Copyright (c) 2015-2015 Cisco Systems, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +#include "trex_rpc_cmds.h" +#include + +using namespace std; + +/** + * add command + * + */ + +TestRpcAddMethod::TestRpcAddMethod() : TrexRpcCommand("test_rpc_add") { + +} + +TrexRpcCommand::rpc_cmd_rc_e +TestRpcAddMethod::_run(const Json::Value ¶ms, Json::Value &result) { + + const Json::Value &x = params["x"]; + const Json::Value &y = params["y"]; + + /* validate count */ + if (params.size() != 2) { + return (TrexRpcCommand::RPC_CMD_PARAM_COUNT_ERR); + } + + /* check we have all the required paramters */ + if (!x.isInt() || !y.isInt()) { + return (TrexRpcCommand::RPC_CMD_PARAM_PARSE_ERR); + } + + result["result"] = x.asInt() + y.asInt(); + return (RPC_CMD_OK); +} + +/** + * sub command + * + * @author imarom (16-Aug-15) + */ + +TestRpcSubMethod::TestRpcSubMethod() : TrexRpcCommand("test_rpc_sub") { + +} + +TrexRpcCommand::rpc_cmd_rc_e +TestRpcSubMethod::_run(const Json::Value ¶ms, Json::Value &result) { + + const Json::Value &x = params["x"]; + const Json::Value &y = params["y"]; + + /* validate count */ + if (params.size() != 2) { + return (TrexRpcCommand::RPC_CMD_PARAM_COUNT_ERR); + } + + /* check we have all the required paramters */ + if (!x.isInt() || !y.isInt()) { + return (TrexRpcCommand::RPC_CMD_PARAM_PARSE_ERR); + } + + result["result"] = x.asInt() - y.asInt(); + return (RPC_CMD_OK); +} + diff --git a/src/rpc-server/src/commands/trex_rpc_cmds.h b/src/rpc-server/src/commands/trex_rpc_cmds.h new file mode 100644 index 00000000..ea6e1081 --- /dev/null +++ b/src/rpc-server/src/commands/trex_rpc_cmds.h @@ -0,0 +1,46 @@ +/* + Itay Marom + Cisco Systems, Inc. +*/ + +/* +Copyright (c) 2015-2015 Cisco Systems, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef __TREX_RPC_CMD_H__ +#define __TREX_RPC_CMD_H__ + +#include +#include + +/* all the RPC commands decl. goes here */ + +/******************* test section ************/ +class TestRpcAddMethod : public TrexRpcCommand { +public: + TestRpcAddMethod(); +protected: + virtual rpc_cmd_rc_e _run(const Json::Value ¶ms, Json::Value &result); +}; + +class TestRpcSubMethod : public TrexRpcCommand { +public: + TestRpcSubMethod(); +protected: + virtual rpc_cmd_rc_e _run(const Json::Value ¶ms, Json::Value &result); +}; + +/**************** test section end *************/ +#endif /* __TREX_RPC_CMD_H__ */ diff --git a/src/rpc-server/src/trex_rpc_cmds_table.cpp b/src/rpc-server/src/trex_rpc_cmds_table.cpp new file mode 100644 index 00000000..4bc1ef29 --- /dev/null +++ b/src/rpc-server/src/trex_rpc_cmds_table.cpp @@ -0,0 +1,50 @@ +/* + Itay Marom + Cisco Systems, Inc. +*/ + +/* +Copyright (c) 2015-2015 Cisco Systems, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +#include +#include + +#include "commands/trex_rpc_cmds.h" + +using namespace std; + +/************* table related methods ***********/ +TrexRpcCommandsTable::TrexRpcCommandsTable() { + /* add the test command (for gtest) */ + register_command(new TestRpcAddMethod()); + register_command(new TestRpcSubMethod()); +} + +TrexRpcCommandsTable::~TrexRpcCommandsTable() { + for (auto cmd : m_rpc_cmd_table) { + delete cmd.second; + } +} + +TrexRpcCommand * TrexRpcCommandsTable::lookup(const string &method_name) { + return m_rpc_cmd_table[method_name]; +} + + +void TrexRpcCommandsTable::register_command(TrexRpcCommand *command) { + + m_rpc_cmd_table[command->get_name()] = command; +} + diff --git a/src/rpc-server/src/trex_rpc_commands.cpp b/src/rpc-server/src/trex_rpc_commands.cpp deleted file mode 100644 index 8547384a..00000000 --- a/src/rpc-server/src/trex_rpc_commands.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - Itay Marom - Cisco Systems, Inc. -*/ - -/* -Copyright (c) 2015-2015 Cisco Systems, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -#include -#include -#include - -using namespace std; - -/***************** commands **********/ -class TestRpcAddRpcMethod : public TrexRpcCommand { -public: - - TestRpcAddRpcMethod() : TrexRpcCommand("test_rpc_add") { - } - - virtual rpc_cmd_rc_e _run(const Json::Value ¶ms, std::string &output) { - const Json::Value &x = params["x"]; - const Json::Value &y = params["y"]; - - /* validate count */ - if (params.size() != 2) { - return (TrexRpcCommand::RPC_CMD_PARAM_COUNT_ERR); - } - - /* check we have all the required paramters */ - if (!x.isInt() || !y.isInt()) { - return (TrexRpcCommand::RPC_CMD_PARAM_PARSE_ERR); - } - - std::stringstream ss; - ss << (x.asInt() + y.asInt()); - output = ss.str(); - - return (RPC_CMD_OK); - } -}; - -/*************** generic command methods *********/ - -TrexRpcCommand::TrexRpcCommand(const string &method_name) : m_name(method_name) { -} - -TrexRpcCommand::rpc_cmd_rc_e -TrexRpcCommand::run(const Json::Value ¶ms, std::string &output) { - return _run(params, output); -} - -const string & TrexRpcCommand::get_name() { - return m_name; -} - - -/************* table related methods ***********/ -TrexRpcCommandsTable::TrexRpcCommandsTable() { - /* add the test command (for gtest) */ - register_command(new TestRpcAddRpcMethod()); - - TrexRpcCommand *cmd = m_rpc_cmd_table["test_rpc_add"]; -} - -TrexRpcCommand * TrexRpcCommandsTable::lookup(const string &method_name) { - return m_rpc_cmd_table[method_name]; -} - - -void TrexRpcCommandsTable::register_command(TrexRpcCommand *command) { - - m_rpc_cmd_table[command->get_name()] = command; -} diff --git a/src/rpc-server/src/trex_rpc_jsonrpc_v2.cpp b/src/rpc-server/src/trex_rpc_jsonrpc_v2.cpp index 2eec599a..53811d70 100644 --- a/src/rpc-server/src/trex_rpc_jsonrpc_v2.cpp +++ b/src/rpc-server/src/trex_rpc_jsonrpc_v2.cpp @@ -20,7 +20,8 @@ limitations under the License. */ #include #include -#include +#include +#include #include @@ -65,13 +66,13 @@ public: } virtual void _execute(Json::Value &response) { - std::string output; + Json::Value result; - TrexRpcCommand::rpc_cmd_rc_e rc = m_cmd->run(m_params, output); + TrexRpcCommand::rpc_cmd_rc_e rc = m_cmd->run(m_params, result); switch (rc) { case TrexRpcCommand::RPC_CMD_OK: - response["result"] = output; + response["result"] = result["result"]; break; case TrexRpcCommand::RPC_CMD_PARAM_COUNT_ERR: @@ -84,8 +85,8 @@ public: } virtual void _execute() { - std::string output; - m_cmd->run(m_params, output); + Json::Value result; + m_cmd->run(m_params, result); } private: diff --git a/src/rpc-server/src/trex_rpc_req_resp.cpp b/src/rpc-server/src/trex_rpc_req_resp.cpp index 7acd1e09..e533c4f2 100644 --- a/src/rpc-server/src/trex_rpc_req_resp.cpp +++ b/src/rpc-server/src/trex_rpc_req_resp.cpp @@ -99,6 +99,7 @@ void TrexRpcServerReqRes::handle_request(const std::string &request) { Json::Value single_response; command->execute(single_response); + delete command; response[index++] = single_response; diff --git a/src/rpc-server/src/trex_rpc_server.cpp b/src/rpc-server/src/trex_rpc_server.cpp index 3f6f5107..5c29b6d7 100644 --- a/src/rpc-server/src/trex_rpc_server.cpp +++ b/src/rpc-server/src/trex_rpc_server.cpp @@ -92,6 +92,7 @@ void TrexRpcServerInterface::stop() { /* hold until thread has joined */ m_thread->join(); + delete m_thread; } bool TrexRpcServerInterface::is_running() { -- cgit 1.2.3-korg