From patchwork Wed Oct 1 13:46:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pattan, Reshma" X-Patchwork-Id: 693 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 1D11DE82; Wed, 1 Oct 2014 15:40:43 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 9DD3ADE4 for ; Wed, 1 Oct 2014 15:40:41 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 01 Oct 2014 06:46:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,632,1406617200"; d="scan'208";a="581884586" Received: from irsmsx104.ger.corp.intel.com ([163.33.3.159]) by orsmga001.jf.intel.com with ESMTP; 01 Oct 2014 06:46:52 -0700 Received: from irsmsx110.ger.corp.intel.com (163.33.3.25) by IRSMSX104.ger.corp.intel.com (163.33.3.159) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 1 Oct 2014 14:46:42 +0100 Received: from irsmsx109.ger.corp.intel.com ([169.254.13.253]) by IRSMSX110.ger.corp.intel.com ([169.254.15.199]) with mapi id 14.03.0195.001; Wed, 1 Oct 2014 14:46:41 +0100 From: "Pattan, Reshma" To: "dev@dpdk.org" Thread-Topic: [PATCH v4] distributor_app: gracefull shutdown of tx/rx threads on SIGINT Thread-Index: AQHP3Xxd20ZWD398c0qzZabn1W8zupwbQPyA Date: Wed, 1 Oct 2014 13:46:41 +0000 Message-ID: <3AEA2BF9852C6F48A459DA490692831FE20F81@IRSMSX109.ger.corp.intel.com> References: <1412073577-12248-1-git-send-email-reshma.pattan@intel.com> <1412170427-7245-1-git-send-email-reshma.pattan@intel.com> In-Reply-To: <1412170427-7245-1-git-send-email-reshma.pattan@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.181] MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v4] distributor_app: gracefull shutdown of tx/rx threads on SIGINT X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Self-NAK. Reason: Incomplete patch. Will send updated next version soon. -----Original Message----- From: Pattan, Reshma Sent: Wednesday, October 1, 2014 2:34 PM To: dev@dpdk.org Cc: Pattan, Reshma Subject: [PATCH v4] distributor_app: gracefull shutdown of tx/rx threads on SIGINT From: Reshma Pattan *Handled gracefull shutdown of rx and tx threads upon SIGINT. *Gracefull shutdown of worker threads will be handled in future enhancements. Signed-off-by: Reshma Pattan --- examples/distributor_app/main.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) } printf("\nCore %u doing packet TX.\n", rte_lcore_id()); - for (;;) { + while (!quit_signal) { for (port = 0; port < nb_ports; port++) { /* skip ports that are not enabled */ if ((enabled_port_mask & (1 << port)) == 0) @@ -370,7 +371,6 @@ lcore_tx(struct rte_ring *in_r) } } - static __attribute__((noreturn)) void lcore_worker(struct lcore_params *p) { @@ -415,7 +415,7 @@ int_handler(int sig_num) printf(" - Out Errs: %"PRIu64"\n", eth_stats.oerrors); printf(" - Mbuf Errs: %"PRIu64"\n", eth_stats.rx_nombuf); } - exit(0); + quit_signal = 1; } /* display usage */ -- 1.7.4.1 -------------------------------------------------------------- Intel Shannon Limited Registered in Ireland Registered Office: Collinstown Industrial Park, Leixlip, County Kildare Registered Number: 308263 Business address: Dromore House, East Park, Shannon, Co. Clare This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. diff --git a/examples/distributor_app/main.c b/examples/distributor_app/main.c index f555d93..b6fa063 100644 --- a/examples/distributor_app/main.c +++ b/examples/distributor_app/main.c @@ -85,6 +85,7 @@ /* mask of enabled ports */ static uint32_t enabled_port_mask = 0; +volatile uint8_t quit_signal = 0; static volatile struct app_stats { struct { @@ -221,7 +222,7 @@ struct lcore_params { struct rte_ring *r; }; -static __attribute__((noreturn)) void +static int lcore_rx(struct lcore_params *p) { struct rte_distributor *d = p->d; @@ -244,7 +245,7 @@ lcore_rx(struct lcore_params *p) printf("\nCore %u doing packet RX.\n", rte_lcore_id()); port = 0; - for (;;) { + while (!quit_signal) { /* skip ports that are not enabled */ if ((enabled_port_mask & (1 << port)) == 0) { if (++port == nb_ports) @@ -307,7 +308,7 @@ flush_all_ports(struct output_buffer *tx_buffers, uint8_t nb_ports) } } -static __attribute__((noreturn)) void +static int lcore_tx(struct rte_ring *in_r) { static struct output_buffer tx_buffers[RTE_MAX_ETHPORTS]; @@ -328,7 +329,7 @@ lcore_tx(struct rte_ring *in_r)