This reverts commit 9a0b3c409db1963a92d0a91868b1e45254845a8c.

With that change the primary calls rte_eal_cleanup() on SIGINT
while secondaries are still polling the shared queues, which
crashes the secondaries.

Doing shutdown correctly in a multi-process application needs
both processes to monitor each other and handle termination and
unexpected exit. That is too complex for an example; go back to
the simple exit from the signal handler.

Bugzilla ID: 2069

Signed-off-by: Stephen Hemminger <[email protected]>
---
v2 - need to mark arg unused

 examples/multi_process/symmetric_mp/main.c | 30 +++++++++-------------
 1 file changed, 12 insertions(+), 18 deletions(-)

diff --git a/examples/multi_process/symmetric_mp/main.c 
b/examples/multi_process/symmetric_mp/main.c
index e2d185ab1b..05f61abedb 100644
--- a/examples/multi_process/symmetric_mp/main.c
+++ b/examples/multi_process/symmetric_mp/main.c
@@ -92,17 +92,15 @@ smp_usage(const char *prgname, const char *errmsg)
 }
 
 
-/* Set by SIGTERM and SIGINT handler to stop the forwarding loops. */
-static volatile sig_atomic_t quit;
-
-static void
-signal_handler(__rte_unused int signum)
-{
-       quit = 1;
-}
-
+/*
+ * Signal handler configured for SIGTERM and SIGINT to print stats on exit
+ *
+ * This is not safe way to exit for a real production application; it is just 
an example.
+ * Doing proper shutdown with primary/secondary requires process monitoring
+ * and rendezvous.
+ */
 static void
-print_stats(void)
+print_stats(int signum)
 {
        unsigned i;
 
@@ -111,6 +109,7 @@ print_stats(void)
                printf("Port %u: RX - %u, TX - %u, Drop - %u\n", 
(unsigned)p_num,
                                pstats[p_num].rx, pstats[p_num].tx, 
pstats[p_num].drop);
        }
+       exit(0);
 }
 
 /* Parse the argument given in the command line of the application */
@@ -351,7 +350,7 @@ lcore_main(void *arg __rte_unused)
         * queue number corresponding to our process number (not lcore id)
         */
 
-       while (!quit) {
+       for (;;) {
                struct rte_mbuf *buf[PKT_BURST];
 
                for (p = start_port; p < end_port; p++) {
@@ -371,8 +370,6 @@ lcore_main(void *arg __rte_unused)
                        }
                }
        }
-
-       return 0;
 }
 
 /* Check the link status of all ports in up to 9s, and print them finally */
@@ -449,8 +446,8 @@ main(int argc, char **argv)
        struct rte_mempool *mp;
 
        /* set up signal handlers to print stats on exit */
-       signal(SIGINT, signal_handler);
-       signal(SIGTERM, signal_handler);
+       signal(SIGINT, print_stats);
+       signal(SIGTERM, print_stats);
 
        /* initialise the EAL for all */
        ret = rte_eal_init(argc, argv);
@@ -493,9 +490,6 @@ main(int argc, char **argv)
        RTE_LOG(INFO, APP, "Finished Process Init.\n");
 
        rte_eal_mp_remote_launch(lcore_main, NULL, CALL_MAIN);
-       rte_eal_mp_wait_lcore();
-
-       print_stats();
 
        /* clean up the EAL */
        rte_eal_cleanup();
-- 
2.53.0

Reply via email to