On 9/15/2023 9:56 AM, ok...@kernel.org wrote:
From: Sinan Kaya <ok...@kernel.org>
Header format doesn't requires to add "From: "
as author "Signed-off" is already present.
Cleanup event registry during shutdown to prevent memory
leaks.
Signed-off-by: Sinan Kaya <ok...@kernel.org>
Acked-by: Aman Singh <aman.deep.si...@intel.com>
---
app/test-pmd/testpmd.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index c6ad9b18bf..1de7b7cd51 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -4009,6 +4009,28 @@ register_eth_event_callback(void)
return 0;
}
+static int
+unregister_eth_event_callback(void)
+{
+ int ret;
+ enum rte_eth_event_type event;
+
+ for (event = RTE_ETH_EVENT_UNKNOWN;
+ event < RTE_ETH_EVENT_MAX; event++) {
+ ret = rte_eth_dev_callback_unregister(RTE_ETH_ALL,
+ event,
+ eth_event_callback,
+ NULL);
+ if (ret != 0) {
+ TESTPMD_LOG(ERR, "Failed to unregister callback for "
+ "%s event\n", eth_event_desc[event]);
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
/* This function is used by the interrupt thread */
static void
dev_event_callback(const char *device_name, enum rte_dev_event_type type,
@@ -4737,6 +4759,11 @@ main(int argc, char** argv)
rte_latencystats_uninit();
#endif
+ ret = unregister_eth_event_callback();
+ if (ret != 0)
+ rte_exit(EXIT_FAILURE, "Cannot unregister for ethdev events");
+
+
ret = rte_eal_cleanup();
if (ret != 0)
rte_exit(EXIT_FAILURE,