The forwarding loop in lcore_main() never terminates, so the rte_eal_cleanup() and return in main() are unreachable. Clang reports this with -Wunreachable-code.
Add a signal handler setting force_quit, as done by l2fwd and others, and test it in the loop. The function is no longer __rte_noreturn, so the existing cleanup now runs on exit. Signed-off-by: Stephen Hemminger <[email protected]> --- examples/rxtx_callbacks/main.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/examples/rxtx_callbacks/main.c b/examples/rxtx_callbacks/main.c index 4682921285..fe26e7cde2 100644 --- a/examples/rxtx_callbacks/main.c +++ b/examples/rxtx_callbacks/main.c @@ -2,7 +2,9 @@ * Copyright(c) 2010-2015 Intel Corporation */ +#include <signal.h> #include <stdalign.h> +#include <stdbool.h> #include <stdint.h> #include <stdlib.h> #include <inttypes.h> @@ -23,6 +25,15 @@ static int hwts_dynfield_offset = -1; +static volatile bool force_quit; + +static void +signal_handler(int signum) +{ + if (signum == SIGINT || signum == SIGTERM) + force_quit = true; +} + static inline rte_mbuf_timestamp_t * hwts_field(struct rte_mbuf *mbuf) { @@ -244,7 +255,7 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool) * Main thread that does the work, reading from INPUT_PORT * and writing to OUTPUT_PORT */ -static __rte_noreturn void +static void lcore_main(void) { uint16_t port; @@ -259,7 +270,7 @@ lcore_main(void) printf("\nCore %u forwarding packets. [Ctrl+C to quit]\n", rte_lcore_id()); - for (;;) { + while (!force_quit) { RTE_ETH_FOREACH_DEV(port) { struct rte_mbuf *bufs[BURST_SIZE]; const uint16_t nb_rx = rte_eth_rx_burst(port, 0, @@ -301,6 +312,10 @@ main(int argc, char *argv[]) if (ret < 0) rte_exit(EXIT_FAILURE, "Error with EAL initialization\n"); + + signal(SIGINT, signal_handler); + signal(SIGTERM, signal_handler); + argc -= ret; argv += ret; -- 2.53.0

