DPDK patches and discussions
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@redhat.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: dev@dpdk.org
Subject: Re: [PATCH] testpmd: fix early exit from signal
Date: Fri, 27 Oct 2023 09:30:14 +0200	[thread overview]
Message-ID: <CAJFAV8z_LZUdqauHybLOVWmSykckXPF_LmbUU1jJhOhmaPffyQ@mail.gmail.com> (raw)
In-Reply-To: <20231026171133.250715-1-stephen@networkplumber.org>

On Thu, Oct 26, 2023 at 7:11 PM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> Other signals may occur causing read to get interrupted.
> Loop until quit flag is set by signal, a character is entered,
> or end of file. This fixes bug where testpmd would exit early
> because of signal used by TAP device.
>
> Bugzilla ID: 1305
> Fixes: 0fd1386c30c3 ("app/testpmd: cleanup cleanly from signal")

We need this fix in LTS.
Cc: stable@dpdk.org


> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  app/test-pmd/testpmd.c | 26 +++++++++-----------------
>  1 file changed, 9 insertions(+), 17 deletions(-)
>
> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
> index 595b77748c2a..619a59f5b891 100644
> --- a/app/test-pmd/testpmd.c
> +++ b/app/test-pmd/testpmd.c
> @@ -11,7 +11,6 @@
>  #include <fcntl.h>
>  #ifndef RTE_EXEC_ENV_WINDOWS
>  #include <sys/mman.h>
> -#include <sys/select.h>
>  #endif
>  #include <sys/types.h>
>  #include <errno.h>
> @@ -4743,25 +4742,18 @@ main(int argc, char** argv)
>                         }
>                 } else {
>                         char c;
> -                       fd_set fds;
>
>                         printf("Press enter to exit\n");
> +                       while (f_quit == 0) {
> +                               /* end-of-file or any character exits loop */
> +                               if (read(0, &c, 1) >= 0)
> +                                       break;
>
> -                       FD_ZERO(&fds);
> -                       FD_SET(0, &fds);
> -
> -                       /* wait for signal or enter */
> -                       ret = select(1, &fds, NULL, NULL, NULL);
> -                       if (ret < 0 && errno != EINTR)
> -                               rte_exit(EXIT_FAILURE,
> -                                        "Select failed: %s\n",
> -                                        strerror(errno));
> -
> -                       /* if got enter then consume it */
> -                       if (ret == 1 && read(0, &c, 1) < 0)
> -                               rte_exit(EXIT_FAILURE,
> -                                        "Read failed: %s\n",
> -                                        strerror(errno));
> +                               if (errno == EINTR)
> +                                       continue;
> +                               rte_exit(EXIT_FAILURE, "Read failed: %s\n",
> +                                                strerror(errno));

Just a nit here.
Indent seems odd, I see an extra whitespace.

Otherwise the fix lgtm and resolves the issue reported in bz.
Reviewed-by: David Marchand <david.marchand@redhat.com>


-- 
David Marchand


  parent reply	other threads:[~2023-10-27  7:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-26 17:11 Stephen Hemminger
2023-10-27  0:18 ` Ferruh Yigit
2023-10-27  7:30 ` David Marchand [this message]
2023-10-27 12:30   ` Ferruh Yigit

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=CAJFAV8z_LZUdqauHybLOVWmSykckXPF_LmbUU1jJhOhmaPffyQ@mail.gmail.com \
    --to=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=stephen@networkplumber.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).