From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D4569A0505; Tue, 17 May 2022 18:32:17 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BCB4940041; Tue, 17 May 2022 18:32:17 +0200 (CEST) Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by mails.dpdk.org (Postfix) with ESMTP id 760D94003C for ; Tue, 17 May 2022 18:32:16 +0200 (CEST) Received: by mail-pf1-f180.google.com with SMTP id bo5so17345720pfb.4 for ; Tue, 17 May 2022 09:32:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=02l6nNDKWOru1VkqktbvD3Ue0CF8pZkkH58sHNb+ggE=; b=g83Qt+6EnITMcWnxwNT+KpEGLmpphYeI0T+dvfCDAV70MOn/N/vEGVZW5Ool/t+mSG 4fNKOm4le2AgNoRCVPYMqiKI5XHP2HI58/lZoo149Zk9MGlR0mQblIxqt+UI+cC2y90M lxN397XvU6NUBqvFv0xZRK4Za/1hBy3n2rBQCbEoPbamb9IQuwW7Xuc7pvn2VMDntLqH oZlC0vXkiBllxeGVqQUxwlqcEj738MYhUwta46JaF7Ql8kkDULp8uziSSG11MvkjedPF HnRG/Gn6PkYclkd1WwlpPxjk7Rrs5p8BuBx60xsvqODUsctc/IBMSSq5em0ai2pGsOfI GHtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=02l6nNDKWOru1VkqktbvD3Ue0CF8pZkkH58sHNb+ggE=; b=z0wY6e1UdZsJuLu7BKo7FtQRxT7YMUdjbkViGGXzGbuNRvCq1H8Z5XQL6y0diGo8tj nkX+4JVsF3wMFiCDR646xRdybfQ6nb+krRgAb1DsNS09x11y0tzHWx+Q2Ugo8fDmZgnA hLcYZOPkEjLgJDrQUjR0WUFnYe8kOwYzWzARSt3UASqz8L53NLXL78MZU1Pq6ErralxL hce8F4MFp+X8iXYWsliLj5aWKXm0IooJPC0lAqhYaOLTJZivHYhHW0xQwKbdwaPRmaw9 s3BdmG+biAZQBgCWoyAGn5Ii3nYHf4/+lCNVk1S/EL4hX3iqkR3cQw4mWLVvjFiJa/Ya rIow== X-Gm-Message-State: AOAM531nQu8R93cVOjZWKrB6TQUgDoeRpUmwtK+GMUgN64QFOsJRQ1Se b7agmJCeRyJVsArOtO4qw7cyaw== X-Google-Smtp-Source: ABdhPJw5vJKrN7RKg5StQSEFxSlPmiFsICCgTaH56xZHeR/wF79WL0Fz06W3AnGXufhADE3JDauXEw== X-Received: by 2002:a05:6a00:234f:b0:4f6:f0c0:ec68 with SMTP id j15-20020a056a00234f00b004f6f0c0ec68mr23477558pfj.14.1652805135608; Tue, 17 May 2022 09:32:15 -0700 (PDT) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id h126-20020a62de84000000b00518151a5a25sm5471pfg.108.2022.05.17.09.32.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 09:32:15 -0700 (PDT) Date: Tue, 17 May 2022 09:32:12 -0700 From: Stephen Hemminger To: Gagandeep Singh Cc: gakhil@marvell.com, dev@dpdk.org Subject: Re: [PATCH v2 3/7] examples/l2fwd-crypto: add signal handler for exit Message-ID: <20220517093212.71b8019c@hermes.local> In-Reply-To: <20220517033858.40394-4-g.singh@nxp.com> References: <20220425041423.2232034-1-g.singh@nxp.com> <20220517033858.40394-1-g.singh@nxp.com> <20220517033858.40394-4-g.singh@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Tue, 17 May 2022 09:08:54 +0530 Gagandeep Singh wrote: > Handle SIGINT and SIGTERM signals. > > Signed-off-by: Gagandeep Singh > --- > 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 > #include > #include > +#include > > #include > #include > @@ -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.