#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;
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')
}
}
+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;
void unreg_input_tcp(void);
void unreg_input_uds(void);
+void stop_handling_client(void);
#endif /* _INPUT_CONN_H_ */
if (STR_EQ(str, "enable bypass")) {
return parse_flag(&pset->flags, DSF_ENABLE_BYPASS, pkey);
}
+ if (STR_EQ(str, "heartbeat timeout")) {
+ return parse_int(&pset->heartbeat_timeout, pkey);
+ }
if (STR_EQ(str, "cpe table map")) {
/* The config defined ports through 0, 1, 2 ... which
uint32_t logbuf_size;
uint32_t logbuf_pos;
char *logbuf;
+ uint32_t heartbeat_timeout;
+ uint64_t heartbeat_tsc;
};
extern struct prox_cfg prox_cfg;
if (stop_tsc && rte_rdtsc() >= stop_tsc) {
stop_prox = 1;
}
+ if ((prox_cfg.heartbeat_tsc) && (prox_cfg.heartbeat_timeout) && (rte_rdtsc() >= prox_cfg.heartbeat_tsc)) {
+ plog_info("Stopping to handle client as heartbeat timed out\n");
+ stop_core_all(-1);
+ stop_handling_client();
+ req_refresh();
+ prox_cfg.heartbeat_tsc = 0;
+ }
}
} else {
while (stop_prox == 0) {
if (stop_tsc && rte_rdtsc() >= stop_tsc) {
stop_prox = 1;
}
+ if ((prox_cfg.heartbeat_tsc) && (prox_cfg.heartbeat_timeout) && (rte_rdtsc() >= prox_cfg.heartbeat_tsc)) {
+ plog_info("Stopping to handle client as heartbeat timed out\n");
+ stop_core_all(-1);
+ stop_handling_client();
+ req_refresh();
+ prox_cfg.heartbeat_tsc = 0;
+ }
}
}