ioat: clean up on exit in examples
Previously, the cleanup functions were only being called if there was an error during initialization. Change-Id: I1606cfa9a9c3732d670131f78249d34a5db47403 Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
d4ab30ba33
commit
25cad6ffcf
@ -112,7 +112,9 @@ ioat_exit(void)
|
||||
while (!TAILQ_EMPTY(&g_devices)) {
|
||||
dev = TAILQ_FIRST(&g_devices);
|
||||
TAILQ_REMOVE(&g_devices, dev, tailq);
|
||||
ioat_detach(dev->ioat);
|
||||
if (dev->ioat) {
|
||||
ioat_detach(dev->ioat);
|
||||
}
|
||||
rte_free(dev);
|
||||
}
|
||||
}
|
||||
@ -406,6 +408,7 @@ main(int argc, char **argv)
|
||||
{
|
||||
unsigned lcore_id;
|
||||
struct thread_entry threads[RTE_MAX_LCORE] = {};
|
||||
int rc;
|
||||
|
||||
if (parse_args(argc, argv) != 0) {
|
||||
return 1;
|
||||
@ -422,14 +425,21 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (work_fn(&threads[rte_get_master_lcore()]) != 0) {
|
||||
return 1;
|
||||
rc = 1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
RTE_LCORE_FOREACH_SLAVE(lcore_id) {
|
||||
if (rte_eal_wait_lcore(lcore_id) != 0) {
|
||||
return 1;
|
||||
rc = 1;
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
return dump_result(threads, RTE_MAX_LCORE);
|
||||
rc = dump_result(threads, RTE_MAX_LCORE);
|
||||
|
||||
cleanup:
|
||||
ioat_exit();
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
@ -113,8 +113,10 @@ ioat_exit(void)
|
||||
while (!TAILQ_EMPTY(&g_devices)) {
|
||||
dev = TAILQ_FIRST(&g_devices);
|
||||
TAILQ_REMOVE(&g_devices, dev, tailq);
|
||||
ioat_detach(dev->ioat);
|
||||
rte_free(dev);
|
||||
if (dev->ioat) {
|
||||
ioat_detach(dev->ioat);
|
||||
}
|
||||
free(dev);
|
||||
}
|
||||
}
|
||||
static void prepare_ioat_task(struct thread_entry *thread_entry, struct ioat_task *ioat_task)
|
||||
@ -408,6 +410,7 @@ main(int argc, char **argv)
|
||||
{
|
||||
unsigned lcore_id;
|
||||
struct thread_entry threads[RTE_MAX_LCORE] = {};
|
||||
int rc;
|
||||
|
||||
if (parse_args(argc, argv) != 0) {
|
||||
return 1;
|
||||
@ -424,16 +427,22 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (work_fn(&threads[rte_get_master_lcore()]) != 0) {
|
||||
return 1;
|
||||
rc = 1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
RTE_LCORE_FOREACH_SLAVE(lcore_id) {
|
||||
if (rte_eal_wait_lcore(lcore_id) != 0) {
|
||||
return 1;
|
||||
rc = 1;
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
rte_free(g_src);
|
||||
rc = dump_result(threads, RTE_MAX_LCORE);
|
||||
|
||||
return dump_result(threads, RTE_MAX_LCORE);
|
||||
cleanup:
|
||||
rte_free(g_src);
|
||||
ioat_exit();
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user