test/distributor: fix mbuf leak on failure
rte_mempool_get_bulk is used to get bufs/many_bufs from the pool,
but at some locations when test fails the bufs/many_bufs are
not returned back to the pool.
Due to this, multiple executions of distributor_autotest gives the
following error message: Error getting mbufs from pool.
To resolve this issue rte_mempool_put_bulk is used whenever the test
fails and returns.
Fixes: c3eabff124
("distributor: add unit tests")
Cc: stable@dpdk.org
Signed-off-by: Sarosh Arif <sarosh.arif@emumba.com>
Acked-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Reviewed-by: David Hunt <david.hunt@intel.com>
This commit is contained in:
parent
f72bff0ec2
commit
0e8704a453
@ -134,6 +134,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)
|
||||
printf("Line %d: Error, not all packets flushed. "
|
||||
"Expected %u, got %u\n",
|
||||
__LINE__, BURST, total_packet_count());
|
||||
rte_mempool_put_bulk(p, (void *)bufs, BURST);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -160,6 +161,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)
|
||||
printf("Line %d: Error, not all packets flushed. "
|
||||
"Expected %u, got %u\n",
|
||||
__LINE__, BURST, total_packet_count());
|
||||
rte_mempool_put_bulk(p, (void *)bufs, BURST);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -188,6 +190,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)
|
||||
printf("Line %d: Error, not all packets flushed. "
|
||||
"Expected %u, got %u\n",
|
||||
__LINE__, BURST, total_packet_count());
|
||||
rte_mempool_put_bulk(p, (void *)bufs, BURST);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -243,6 +246,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)
|
||||
if (num_returned != BIG_BATCH) {
|
||||
printf("line %d: Missing packets, expected %d\n",
|
||||
__LINE__, num_returned);
|
||||
rte_mempool_put_bulk(p, (void *)many_bufs, BIG_BATCH);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -257,6 +261,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)
|
||||
|
||||
if (j == BIG_BATCH) {
|
||||
printf("Error: could not find source packet #%u\n", i);
|
||||
rte_mempool_put_bulk(p, (void *)many_bufs, BIG_BATCH);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user