From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 07C80A052B; Thu, 30 Jul 2020 23:15:29 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BE0402BB8; Thu, 30 Jul 2020 23:15:28 +0200 (CEST) Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by dpdk.org (Postfix) with ESMTP id C6E8010A3 for ; Thu, 30 Jul 2020 23:15:26 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 12EE65C0189; Thu, 30 Jul 2020 17:15:25 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Thu, 30 Jul 2020 17:15:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s=fm1; bh= 0MhvvsnI33N2dgfJFR5DyXcX/3/fYo+r8zUopEsFkDQ=; b=GyKgGo98ALbzNeXs empN/CHXjljQeAUpXfOovNJWfzyyn6MLF0KMZ4p7LLxutcMS6z6Z37OnrKmkpkKM G7lQbF/1SP+6bi5fr2vKVUkjWqsxLuXN/xBGaPb4vY8afrgudUnqwiOJvfG268Oc MnE7nJSTM/3dWFBcwtdiHIHqc/5AyhhlVPwNiLtP2G1iFhHOQJnYCGa9o9wO+5lK LSbY8+jEaFLbCK3AUQ2qxUEHYugXZNRkPwhTxjIvWn/4fBqATvuhkbxJfIqfSWtx XpEynFcAqr+QDg2U0qoxroU3x/2MhyOdFkSfAZ8jlCmGmvi1O8CINQe1m1GEjo2/ Y8fZVA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=0MhvvsnI33N2dgfJFR5DyXcX/3/fYo+r8zUopEsFk DQ=; b=Mp5SsPMBgCfOjcPfkjZihToNfx0TyRMyvP+58agQnqDHBtZjFZ/K9NNDi HLLTDzvKOl5Npg7UHRYXcRSlvuXIfhTcf1S3HKDtcYa7qo/3PoLYo55gjlaUylQJ k08ZffWe5qkg4osbqqsRVg3u6hdgECe8EQ2xeSUFT7rN2nZScseB97NKLs/tHzxF 2K/66kDRq5lHApQYWTkd+fr/B3qmLGaaKMV7M5nwdOyg+py2VGe6VarYODmbyG/+ /E3Tg16a4kDFdmZUwIUOf/5H/IaJnWZh3LiSpdHj7ojVq+GfCbyMyEp6uhEQFaoL L9vJvP+tHuUhJumEPO1M9fPe+Redw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrieeigdduiedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkfgjfhgggfgtsehtufertddttddvnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg ftrfgrthhtvghrnhepudeggfdvfeduffdtfeeglefghfeukefgfffhueejtdetuedtjeeu ieeivdffgeehnecukfhppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl ohhnrdhnvght X-ME-Proxy: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id DA9EF3280060; Thu, 30 Jul 2020 17:15:22 -0400 (EDT) From: Thomas Monjalon To: Ibtisam Tariq Cc: declan.doherty@intel.com, dev@dpdk.org, akhil.goyal@nxp.com, anoobj@marvell.com, bruce.richardson@intel.com, fiona.trahe@intel.com, ruifeng.wang@arm.com, pablo.de.lara.guarch@intel.com Date: Thu, 30 Jul 2020 23:15:21 +0200 Message-ID: <3232006.abz6jIGztJ@thomas> In-Reply-To: <20200722125026.2595-2-ibtisam.tariq@emumba.com> References: <20200722125026.2595-1-ibtisam.tariq@emumba.com> <20200722125026.2595-2-ibtisam.tariq@emumba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH 2/2] examples/l2fwd-crypto: Free resources on exit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Declan is not reviewing patches anymore. Adding more maintainers in Cc. PS: Maybe we should update the file MAINTAINERS to avoid patches being stuck. 22/07/2020 14:50, Ibtisam Tariq: > When exiting the application, resources should be cleared. > > Signed-off-by: Ibtisam Tariq > --- > examples/l2fwd-crypto/main.c | 31 ++++++++++++++++++++++++++++++- > 1 file changed, 30 insertions(+), 1 deletion(-) > > diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c > index 827da9b3e..5b00e2ade 100644 > --- a/examples/l2fwd-crypto/main.c > +++ b/examples/l2fwd-crypto/main.c > @@ -18,6 +18,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -47,6 +48,8 @@ > #include > #endif > > +static volatile bool force_quit; > + > enum cdev_type { > CDEV_TYPE_ANY, > CDEV_TYPE_HW, > @@ -838,7 +841,7 @@ l2fwd_main_loop(struct l2fwd_crypto_options *options) > * so user can see the crypto information. > */ > prev_tsc = rte_rdtsc(); > - while (1) { > + while (!force_quit) { > > cur_tsc = rte_rdtsc(); > > @@ -1738,8 +1741,12 @@ check_all_ports_link_status(uint32_t port_mask) > printf("\nChecking link status"); > fflush(stdout); > for (count = 0; count <= MAX_CHECK_TIME; count++) { > + if (force_quit) > + return; > all_ports_up = 1; > RTE_ETH_FOREACH_DEV(portid) { > + if (force_quit) > + return; > if ((port_mask & (1 << portid)) == 0) > continue; > memset(&link, 0, sizeof(link)); > @@ -2662,6 +2669,16 @@ reserve_key_memory(struct l2fwd_crypto_options *options) > options->aad.phys_addr = rte_malloc_virt2iova(options->aad.data); > } > > +static void > +signal_handler(int signum) > +{ > + if (signum == SIGINT || signum == SIGTERM) { > + printf("\n\nSignal %d received, preparing to exit...\n", > + signum); > + force_quit = true; > + } > +} > + > int > main(int argc, char **argv) > { > @@ -2681,6 +2698,10 @@ main(int argc, char **argv) > argc -= ret; > argv += ret; > > + force_quit = false; > + signal(SIGINT, signal_handler); > + signal(SIGTERM, signal_handler); > + > /* reserve memory for Cipher/Auth key and IV */ > reserve_key_memory(&options); > > @@ -2807,6 +2828,14 @@ main(int argc, char **argv) > if (rte_eal_wait_lcore(lcore_id) < 0) > return -1; > } > + RTE_ETH_FOREACH_DEV(portid) { > + printf("Closing port %d...", portid); > + rte_eth_dev_stop(portid); > + rte_eth_dev_close(portid); > + printf(" Done\n"); > + } > + rte_eal_cleanup(); > + printf("Bye...\n"); > > return 0; > } >