When primary app exits, the residual running pdump will stop the primary app to restart. Add pdump exits with primary support.
Suggested-by: Varghese, Vipin <vipin.vargh...@intel.com> Suggested-by: Burakov, Anatoly <anatoly.bura...@intel.com> Signed-off-by: Suanming.Mou <mousuanm...@huawei.com> --- app/pdump/main.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/app/pdump/main.c b/app/pdump/main.c index 3d20854..cc46f65 100644 --- a/app/pdump/main.c +++ b/app/pdump/main.c @@ -26,6 +26,7 @@ #include <rte_ring.h> #include <rte_string_fns.h> #include <rte_pdump.h> +#include <rte_alarm.h> #define CMD_LINE_OPT_PDUMP "pdump" #define CMD_LINE_OPT_PDUMP_NUM 256 @@ -65,6 +66,7 @@ #define SIZE 256 #define BURST_SIZE 32 #define NUM_VDEVS 2 +#define MONITOR_INTERVAL (500 * 1000) /* true if x is a power of 2 */ #define POWEROF2(x) ((((x)-1) & (x)) == 0) @@ -413,6 +415,18 @@ struct parse_val { } static void +monitor_primary(void *arg __rte_unused) +{ + if (quit_signal) + return; + + if (rte_eal_primary_proc_alive(NULL)) + rte_eal_alarm_set(MONITOR_INTERVAL, monitor_primary, NULL); + else + quit_signal = 1; +} + +static void print_pdump_stats(void) { int i; @@ -537,6 +551,18 @@ struct parse_val { } static void +disable_primary_monitor(void) +{ + int ret; + + /* Don't worry about it is primary exit case. The alarm cancel + * function will take care about that. */ + ret = rte_eal_alarm_cancel(monitor_primary, NULL); + if (ret < 0) + printf("Fail to disable monitor fail:%d\n", ret); +} + +static void signal_handler(int sig_num) { if (sig_num == SIGINT) { @@ -910,6 +936,19 @@ struct parse_val { ; } +static void +enable_primary_monitor(void) +{ + int ret; + + /* Once primary exits, so will pdump. */ + ret = rte_eal_alarm_set(MONITOR_INTERVAL, monitor_primary, NULL); + if (ret < 0) { + cleanup_pdump_resources(); + rte_exit(EXIT_FAILURE, "Fail to monitor primary:%d\n", ret); + } +} + int main(int argc, char **argv) { @@ -950,11 +989,13 @@ struct parse_val { rte_exit(EXIT_FAILURE, "Invalid argument\n"); } - /* create mempool, ring and vdevs info */ + /* create mempool, ring, vdevs info and primary monitor */ create_mp_ring_vdev(); enable_pdump(); + enable_primary_monitor(); dump_packets(); + disable_primary_monitor(); cleanup_pdump_resources(); /* dump debug stats */ print_pdump_stats(); -- 1.8.3.4