The packet handling loop in main() never terminates, so the rte_eal_cleanup() after it is 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 so that cleanup runs on exit. Return zero explicitly rather than falling off the end of main(), and drop the "Never returns" comment which no longer applies. Signed-off-by: Stephen Hemminger <[email protected]> --- examples/server_node_efd/efd_node/node.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/examples/server_node_efd/efd_node/node.c b/examples/server_node_efd/efd_node/node.c index fc2aa5ffef..94ff4e9e0e 100644 --- a/examples/server_node_efd/efd_node/node.c +++ b/examples/server_node_efd/efd_node/node.c @@ -2,6 +2,8 @@ * Copyright(c) 2016-2017 Intel Corporation */ +#include <signal.h> +#include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <inttypes.h> @@ -298,9 +300,18 @@ handle_packets(struct rte_hash *h, struct rte_mbuf **bufs, uint16_t num_packets) } /* >8 End of packets dequeuing. */ +static volatile bool force_quit; + +static void +signal_handler(int signum) +{ + if (signum == SIGINT || signum == SIGTERM) + force_quit = true; +} + /* * Application main function - loops through - * receiving and processing packets. Never returns + * receiving and processing packets until interrupted */ int main(int argc, char *argv[]) @@ -318,6 +329,9 @@ main(int argc, char *argv[]) retval = rte_eal_init(argc, argv); if (retval < 0) return -1; + + signal(SIGINT, signal_handler); + signal(SIGTERM, signal_handler); argc -= retval; argv += retval; @@ -356,7 +370,7 @@ main(int argc, char *argv[]) printf("\nNode process %d handling packets\n", node_id); printf("[Press Ctrl-C to quit ...]\n"); - for (;;) { + while (!force_quit) { uint16_t rx_pkts = PKT_READ_SIZE; uint16_t port; @@ -392,4 +406,6 @@ main(int argc, char *argv[]) /* clean up the EAL */ rte_eal_cleanup(); + + return 0; } -- 2.53.0

