diff options
author | Xavier Simonart <xavier.simonart@intel.com> | 2019-09-04 13:54:31 +0200 |
---|---|---|
committer | Xavier Simonart <xavier.simonart@intel.com> | 2019-09-04 13:54:31 +0200 |
commit | d3552eafaca34771734258f3ff6f4f5f819e72bd (patch) | |
tree | 1955ec75c2d21303f9ee6b6a18a32dfb3da82692 /VNFs/DPPD-PROX/input_conn.c | |
parent | 9033cadea78ca28c726323cb8334c7206fe51c22 (diff) |
Add heartbeat support (stop all cores in case of TCP socket issues)
"heartbeat timeout" (in second) can be specified as a global parameter
in PROX config file. If set, a timer is started when the first
command is received from the TCP socket. This timer is reset at each
commands received through the TCP socket. If the timer expires, then
- all cores are stopped
- the TCP socket is closed, causing an error at client side.
This feature helps in case a script starts PROX and the traffic generated
through PROX causes issues to the control plane.
Change-Id: I900f22fa091786a564f6b7d846f5abc2c5cbcc58
Signed-off-by: Xavier Simonart <xavier.simonart@intel.com>
Diffstat (limited to 'VNFs/DPPD-PROX/input_conn.c')
-rw-r--r-- | VNFs/DPPD-PROX/input_conn.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/VNFs/DPPD-PROX/input_conn.c b/VNFs/DPPD-PROX/input_conn.c index 63e6511e..13d6110e 100644 --- a/VNFs/DPPD-PROX/input_conn.c +++ b/VNFs/DPPD-PROX/input_conn.c @@ -20,10 +20,13 @@ #include <sys/un.h> #include <unistd.h> +#include <rte_cycles.h> #include "input_conn.h" #include "input.h" +#include "log.h" #include "run.h" #include "cmd_parser.h" +#include "prox_cfg.h" static struct input tcp_server; int tcp_server_started; @@ -132,6 +135,8 @@ static void handle_client(struct input* client_input) return ; } + prox_cfg.heartbeat_tsc = rte_rdtsc() + prox_cfg.heartbeat_timeout * rte_get_tsc_hz(); + /* Scan in data until \n (\r skipped if followed by \n) */ for (int i = 0; i < ret; ++i) { if (cur[i] == '\r' && i + 1 < ret && cur[i + 1] == '\n') @@ -150,6 +155,18 @@ static void handle_client(struct input* client_input) } } +void stop_handling_client(void) +{ + size_t i; + for (i = 0; i < sizeof(clients)/sizeof(clients[0]); ++i) { + if (clients[i].enabled) { + close(clients[i].input.fd); + clients[i].enabled = 0; + unreg_input(&clients[i].input); + } + } +} + static void handle_new_client(struct input* server) { size_t i; |