[dpdk-dev,v4] distributor_app: gracefull shutdown of tx/rx threads on SIGINT
Commit Message
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(-)
Comments
> *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>
You have sent a patch which depends of the previous one, right?
It's OK but for next time, please consider these guidelines:
- You should mention that it depends of another pending patch (with its title)
- You should not increment the version number (v4) as it doesn't supersed the
previous one. It's v1 for this patch so no number is required.
Thanks
@@ -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 */