From mboxrd@z Thu Jan 1 00:00:00 1970 From: reshmapa Subject: [PATCH v4] distributor_app: gracefull shutdown of tx/rx threads on SIGINT Date: Wed, 1 Oct 2014 14:33:47 +0100 Message-ID: <1412170427-7245-1-git-send-email-reshma.pattan@intel.com> References: <1412073577-12248-1-git-send-email-reshma.pattan@intel.com> To: dev-VfR2kkLFssw@public.gmane.org Return-path: In-Reply-To: <1412073577-12248-1-git-send-email-reshma.pattan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" 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(-) 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