[dpdk-dev] [PATCH v2] examples/ip_pipeline: Support quitting CLI connection

Liu Hongbo cnliuhb at gmail.com
Wed May 9 14:10:17 CEST 2018


When detecting input "quit", ip_pipeline should close connection fd.
It is convenient when using command "telnet 0 8086".

Signed-off-by: Liu Hongbo <cnliuhb at gmail.com>
---
 examples/ip_pipeline/conn.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/examples/ip_pipeline/conn.c b/examples/ip_pipeline/conn.c
index 9338942..44d7ff8 100644
--- a/examples/ip_pipeline/conn.c
+++ b/examples/ip_pipeline/conn.c
@@ -222,6 +222,8 @@ data_event_handle(struct conn *conn,
 	}
 	if (len == 0)
 		return 0;
+	if (!strncmp(conn->buf, "quit", strlen("quit")))
+		return -2;
 
 	/* Handle input messages */
 	for (i = 0; i < len; i++) {
@@ -316,7 +318,7 @@ conn_poll_for_msg(struct conn *conn)
 		status_data = data_event_handle(conn, fd_client);
 
 	/* Control events */
-	if (event.events & (EPOLLRDHUP | EPOLLERR | EPOLLHUP))
+	if (status_data == -2 || event.events & (EPOLLRDHUP | EPOLLERR | EPOLLHUP))
 		status_control = control_event_handle(conn, fd_client);
 
 	if (status_data || status_control)
-- 
2.7.4



More information about the dev mailing list