Hi Stephen,
> Handle SIGINT and SIGTERM signals.
> 
> Signed-off-by: Gagandeep Singh <g.si...@nxp.com>
> ---
Do you have more comments on this? If not, can you please ack?


>  examples/l2fwd-crypto/main.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
> index b1e2613ccf..bf4b862379 100644
> --- a/examples/l2fwd-crypto/main.c
> +++ b/examples/l2fwd-crypto/main.c
> @@ -18,6 +18,7 @@
>  #include <getopt.h>
>  #include <fcntl.h>
>  #include <unistd.h>
> +#include <signal.h>
> 
>  #include <rte_string_fns.h>
>  #include <rte_branch_prediction.h>
> @@ -256,6 +257,9 @@ struct l2fwd_crypto_statistics
> crypto_statistics[RTE_CRYPTO_MAX_DEVS];
>  #define MAX_TIMER_PERIOD 86400UL /* 1 day max */
>  #define DEFAULT_TIMER_PERIOD 10UL
> 
> +/* Global signal */
> +static volatile bool signal_received;
> +
>  /* Print out statistics on packets dropped */
>  static void
>  print_stats(void)
> @@ -922,6 +926,8 @@ l2fwd_main_loop(struct l2fwd_crypto_options
> *options)
> 
>                       nb_rx = rte_eth_rx_burst(portid, 0,
>                                                pkts_burst, MAX_PKT_BURST);
> +                     if (unlikely(signal_received))
> +                             return;
> 
>                       port_statistics[portid].rx += nb_rx;
> 
> @@ -2760,6 +2766,13 @@ reserve_key_memory(struct l2fwd_crypto_options
> *options)
>       options->aad.phys_addr = rte_malloc_virt2iova(options->aad.data);
>  }
> 
> +static void
> +raise_signal(int signum)
> +{
> +     if (signum == SIGINT || signum == SIGTERM)
> +             signal_received = true;
> +}
> +
>  int
>  main(int argc, char **argv)
>  {
> @@ -2772,6 +2785,9 @@ main(int argc, char **argv)
>       int ret, enabled_cdevcount, enabled_portcount;
>       uint8_t enabled_cdevs[RTE_CRYPTO_MAX_DEVS] = {0};
> 
> +     signal(SIGINT, raise_signal);
> +     signal(SIGTERM, raise_signal);
> +
>       /* init EAL */
>       ret = rte_eal_init(argc, argv);
>       if (ret < 0)
> --
> 2.25.1

Reply via email to