DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v2] examples/ip_pipeline: Support quitting CLI connection
@ 2018-05-09 12:10 Liu Hongbo
  2018-05-09 13:30 ` Dumitrescu, Cristian
  0 siblings, 1 reply; 2+ messages in thread
From: Liu Hongbo @ 2018-05-09 12:10 UTC (permalink / raw)
  To: 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 <cnliuhb@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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [PATCH v2] examples/ip_pipeline: Support quitting CLI connection
  2018-05-09 12:10 [dpdk-dev] [PATCH v2] examples/ip_pipeline: Support quitting CLI connection Liu Hongbo
@ 2018-05-09 13:30 ` Dumitrescu, Cristian
  0 siblings, 0 replies; 2+ messages in thread
From: Dumitrescu, Cristian @ 2018-05-09 13:30 UTC (permalink / raw)
  To: Liu Hongbo, dev



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Liu Hongbo
> Sent: Wednesday, May 9, 2018 1:10 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH v2] examples/ip_pipeline: Support quitting CLI
> connection
> 
> 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@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

Hi Liu,

Thanks for suggesting this, but the quit command is not necessary in the latest IP Pipeline app.

The app is a server waiting for commands from external clients, which can be any decent TCP client such as telnet, netcat, Perl/Python script, etc. The client can be terminated at any time, but the server continues to live on and listen for more client connections. For example, you can kill the telnet client and then later on start another telnet session to the same app. It does not make sense for the client to be able to kill the server.

Regards,
Cristian

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-05-09 13:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-09 12:10 [dpdk-dev] [PATCH v2] examples/ip_pipeline: Support quitting CLI connection Liu Hongbo
2018-05-09 13:30 ` Dumitrescu, Cristian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).