Hi,

> -----Original Message-----
> From: Stephen Hemminger <step...@networkplumber.org>
> Sent: Tuesday, May 17, 2022 10:02 PM
> To: Gagandeep Singh <g.si...@nxp.com>
> Cc: gak...@marvell.com; dev@dpdk.org
> Subject: Re: [PATCH v2 3/7] examples/l2fwd-crypto: add signal handler for exit
> 
> On Tue, 17 May 2022 09:08:54 +0530
> Gagandeep Singh <g.si...@nxp.com> wrote:
> 
> > Handle SIGINT and SIGTERM signals.
> >
> > Signed-off-by: Gagandeep Singh <g.si...@nxp.com>
> > ---
> >  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..0a1fc790fc 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 */
> > +unsigned int signal_received;
> 
> This won't work as expected.
> 
> This kind of flag needs to either be volatile or use explicit atomic builtins
> because the compiler and CPU are free to believe that it never changes.
> 
> Traditional way to address this would be:
> 
> static volatile bool signal_received;
> 
> More advanced way would be to use __atomic_load/store builtin.
> 
> Also printf() is not technically safe to call from a signal handler.

Ok, I will update it to "static volatile bool signal_received;" .

Reply via email to