DPDK patches and discussions
 help / color / mirror / Atom feed
From: hongbo liu <cnliuhb@gmail.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] examples/ip_pipeline: Support quitting CLI connection
Date: Wed, 9 May 2018 19:34:19 +0800	[thread overview]
Message-ID: <CAATCt2SMYfQ7TmGdE5pCDy_3oiEaQrK+iw7-qE=vTSuH_dOcFA@mail.gmail.com> (raw)

When detecting input "quit", ip_pipeline will 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 933894251..44d7ff84a 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.14.1

                 reply	other threads:[~2018-05-09 11:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAATCt2SMYfQ7TmGdE5pCDy_3oiEaQrK+iw7-qE=vTSuH_dOcFA@mail.gmail.com' \
    --to=cnliuhb@gmail.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).