From: Liu Hongbo Subject: [PATCH v2] examples/ip_pipeline: Support quitting CLI connection Date: Wed, 9 May 2018 12:10:17 +0000 Message-ID: <1525867817-6427-1-git-send-email-cnliuhb@gmail.com> To: dev@dpdk.org Return-path: Received: from mail-pl0-f65.google.com (mail-pl0-f65.google.com [209.85.160.65]) by dpdk.org (Postfix) with ESMTP id 0740D6CA3 for ; Wed, 9 May 2018 14:10:31 +0200 (CEST) Received: by mail-pl0-f65.google.com with SMTP id az12-v6so4184435plb.8 for ; Wed, 09 May 2018 05:10:31 -0700 (PDT) Received: from localhost.members.linode.com ([2400:8902::f03c:91ff:fe27:6599]) by smtp.gmail.com with ESMTPSA id i2-v6sm42050490pgo.57.2018.05.09.05.10.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 09 May 2018 05:10:30 -0700 (PDT) List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" When detecting input "quit", ip_pipeline should close connection fd. It is convenient when using command "telnet 0 8086". Signed-off-by: Liu Hongbo --- 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