From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <reshmapa@ecsmtp.ir.intel.com>
Received: from mga01.intel.com (mga01.intel.com [192.55.52.88])
 by dpdk.org (Postfix) with ESMTP id A443E212
 for <dev@dpdk.org>; Wed,  1 Oct 2014 15:27:08 +0200 (CEST)
Received: from fmsmga002.fm.intel.com ([10.253.24.26])
 by fmsmga101.fm.intel.com with ESMTP; 01 Oct 2014 06:33:52 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.04,632,1406617200"; d="scan'208";a="608146917"
Received: from irvmail001.ir.intel.com ([163.33.26.43])
 by fmsmga002.fm.intel.com with ESMTP; 01 Oct 2014 06:33:51 -0700
Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com
 [10.237.217.46])
 by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id
 s91DXnUs030928; Wed, 1 Oct 2014 14:33:49 +0100
Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1])
 by sivswdev02.ir.intel.com with ESMTP id s91DXnWJ007282;
 Wed, 1 Oct 2014 14:33:49 +0100
Received: (from reshmapa@localhost)
 by sivswdev02.ir.intel.com with  id s91DXnUm007278;
 Wed, 1 Oct 2014 14:33:49 +0100
From: reshmapa <reshma.pattan@intel.com>
To: dev@dpdk.org
Date: Wed,  1 Oct 2014 14:33:47 +0100
Message-Id: <1412170427-7245-1-git-send-email-reshma.pattan@intel.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1412073577-12248-1-git-send-email-reshma.pattan@intel.com>
References: <1412073577-12248-1-git-send-email-reshma.pattan@intel.com>
Subject: [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 <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Wed, 01 Oct 2014 13:27:09 -0000

From: Reshma Pattan <reshma.pattan@intel.com>

	*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 <reshma.pattan@intel.com>
---
 examples/distributor_app/main.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

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)
 	}
 
 	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