From: Reshma Pattan <reshma.pat...@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 at 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