summaryrefslogtreecommitdiffstats
path: root/src/rpc-server
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-06-20 13:20:51 +0300
committerimarom <imarom@cisco.com>2016-06-20 13:49:40 +0300
commitf1da3b2bf6817a2ddd8abe8546108b43a12d1411 (patch)
tree92960f8db63e95d7fb9a035fe17d002226dd3956 /src/rpc-server
parente058f6e034fbf51bc5e29d449ea806e7a8633b70 (diff)
more granular lock for RPC server
avoid a bigger jitter for ASYNC thread because of lock
Diffstat (limited to 'src/rpc-server')
-rw-r--r--src/rpc-server/trex_rpc_req_resp_server.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/rpc-server/trex_rpc_req_resp_server.cpp b/src/rpc-server/trex_rpc_req_resp_server.cpp
index 75eec856..e0e7635c 100644
--- a/src/rpc-server/trex_rpc_req_resp_server.cpp
+++ b/src/rpc-server/trex_rpc_req_resp_server.cpp
@@ -201,23 +201,24 @@ void TrexRpcServerReqRes::process_request_raw(const std::string &request, std::s
int index = 0;
- /* expcetion safe */
- std::unique_lock<std::mutex> lock(*m_lock);
-
/* for every command parsed - launch it */
for (auto command : commands) {
Json::Value single_response;
+ /* the command itself should be protected */
+ std::unique_lock<std::mutex> lock(*m_lock);
command->execute(single_response);
+ lock.unlock();
+
delete command;
response_json[index++] = single_response;
+ /* batch is like getting all the messages one by one - it should not be considered as stuck thread */
+ /* need to think if this is a good thing */
+ //m_monitor.tickle();
}
- /* done with the lock */
- lock.unlock();
-
/* write the JSON to string and sever on ZMQ */
if (response.size() == 1) {