Fix thresholds for increment_till_fail
[samplevnf.git] / VNFs / DPPD-PROX / input_conn.c
index 63e6511..13d6110 100644 (file)
 #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;