Skip to contentSkip to conversation

examples/vdpa: fix devices cleanup

PATCH NAK Yajun Wu 2 participants 2 messages Dec 26, 2022

lore
Share & tools
lore

Yajun Wu

author
#0 lore raw

PATCH 1/1 examples/vdpa: fix devices cleanup

Move rte_eal_cleanup to function vdpa_sample_quit which handling all example app quit.
Otherwise rte_eal_cleanup won't be called on receiving signal like SIGINT(control + c).

Fixes 10aa3757 ("examples: add eal cleanup to examples")
---
 examples/vdpa/main.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
examples/vdpa/main.c +2 -3
index 4c7e81d7b6..9149b66538 100644
@@ -287,6 +287,8 @@ vdpa_sample_quit(void)
 		if (vports[i].ifname[0] != '\0')
 			close_vdpa(&vports[i]);
 	}
+	/* clean up the EAL */
+	rte_eal_cleanup();
 }
 
 static void
@@ -633,8 +635,5 @@ main(int argc, char *argv[])
 		vdpa_sample_quit();
 	}
 
-	/* clean up the EAL */
-	rte_eal_cleanup();
-
 	return 0;
 }
Signature · 1 line
2.27.0
#1 lore raw
Quoted 10 lines · On Mon, 26 Dec 2022 14:51:06 +0800 Yajun Wu <[email protected]> wrote:

Move rte_eal_cleanup to function vdpa_sample_quit which handling all example app quit.
Otherwise rte_eal_cleanup won't be called on receiving signal like SIGINT(control + c).

Fixes 10aa3757 ("examples: add eal cleanup to examples")

NAK

rte_eal_cleanup is not signal safe.
This (and several other applications) are not managing termination signals correctly. It is not safe to call many DPDK functions from a signal handler. Imagine the case of getting SIGINT in the middle of a driver holding a spin lock, then calling the close function of that driver which then acquires the same lock.

The only safe way to handle signals is to set a flag and do the shutdown and cleanup from the main loop.