summaryrefslogtreecommitdiffstats
path: root/src/rpc-server
diff options
context:
space:
mode:
Diffstat (limited to 'src/rpc-server')
-rw-r--r--src/rpc-server/trex_rpc_req_resp_server.cpp7
-rw-r--r--src/rpc-server/trex_rpc_server.cpp3
-rw-r--r--src/rpc-server/trex_rpc_server_api.h9
3 files changed, 7 insertions, 12 deletions
diff --git a/src/rpc-server/trex_rpc_req_resp_server.cpp b/src/rpc-server/trex_rpc_req_resp_server.cpp
index 033f265c..75eec856 100644
--- a/src/rpc-server/trex_rpc_req_resp_server.cpp
+++ b/src/rpc-server/trex_rpc_req_resp_server.cpp
@@ -56,7 +56,8 @@ void TrexRpcServerReqRes::_rpc_thread_cb() {
std::stringstream ss;
int zmq_rc;
- m_watchdog_handle = m_watchdog->register_monitor(m_name, 1);
+ m_monitor.create(m_name, 1);
+ TrexWatchDog::getInstance().register_monitor(&m_monitor);
/* create a socket based on the configuration */
@@ -102,7 +103,7 @@ void TrexRpcServerReqRes::_rpc_thread_cb() {
zmq_close(m_socket);
/* done */
- m_watchdog->disable_monitor(m_watchdog_handle);
+ m_monitor.disable();
}
bool
@@ -115,7 +116,7 @@ TrexRpcServerReqRes::fetch_one_request(std::string &msg) {
assert(rc == 0);
while (true) {
- m_watchdog->tickle(m_watchdog_handle);
+ m_monitor.tickle();
rc = zmq_msg_recv (&zmq_msg, m_socket, 0);
if (rc != -1) {
diff --git a/src/rpc-server/trex_rpc_server.cpp b/src/rpc-server/trex_rpc_server.cpp
index e4ca95c3..6c323c16 100644
--- a/src/rpc-server/trex_rpc_server.cpp
+++ b/src/rpc-server/trex_rpc_server.cpp
@@ -36,8 +36,6 @@ TrexRpcServerInterface::TrexRpcServerInterface(const TrexRpcServerConfig &cfg, c
m_name = name;
m_lock = cfg.m_lock;
- m_watchdog = cfg.m_watchdog;
- m_watchdog_handle = -1;
m_is_running = false;
m_is_verbose = false;
@@ -78,7 +76,6 @@ void TrexRpcServerInterface::start() {
/* prepare for run */
_prepare();
- m_watchdog->mark_pending_monitor();
m_thread = new std::thread(&TrexRpcServerInterface::_rpc_thread_cb, this);
if (!m_thread) {
throw TrexRpcException("unable to create RPC thread");
diff --git a/src/rpc-server/trex_rpc_server_api.h b/src/rpc-server/trex_rpc_server_api.h
index 3d9837ef..6df37b17 100644
--- a/src/rpc-server/trex_rpc_server_api.h
+++ b/src/rpc-server/trex_rpc_server_api.h
@@ -30,10 +30,10 @@ limitations under the License.
#include <stdexcept>
#include <trex_rpc_exception_api.h>
#include <json/json.h>
+#include "trex_watchdog.h"
class TrexRpcServerInterface;
class TrexRpcServerReqRes;
-class TrexWatchDog;
/**
* defines a configuration of generic RPC server
@@ -48,11 +48,10 @@ public:
RPC_PROT_MOCK
};
- TrexRpcServerConfig(rpc_prot_e protocol, uint16_t port, std::mutex *lock, TrexWatchDog *watchdog) {
+ TrexRpcServerConfig(rpc_prot_e protocol, uint16_t port, std::mutex *lock) {
m_protocol = protocol;
m_port = port;
m_lock = lock;
- m_watchdog = watchdog;
}
uint16_t get_port() const {
@@ -69,7 +68,6 @@ private:
public:
std::mutex *m_lock;
- TrexWatchDog *m_watchdog;
};
/**
@@ -142,8 +140,7 @@ protected:
std::string m_name;
std::mutex *m_lock;
std::mutex m_dummy_lock;
- TrexWatchDog *m_watchdog;
- int m_watchdog_handle;
+ TrexMonitor m_monitor;
};
/**