diff options
author | Zoltan Kiss <zoltan.kiss@linaro.org> | 2015-07-13 14:43:27 +0100 |
---|---|---|
committer | Maxim Uvarov <maxim.uvarov@linaro.org> | 2015-07-13 17:03:53 +0300 |
commit | f98df8bbdb991fa1257d42924c75847122549db6 (patch) | |
tree | 5fa445f7c922bd1fc318c1c9e3118ae54878b51b /test/performance | |
parent | 4cdf96d25cf2a1a66e89d5ad2cff72306651e4ad (diff) |
test: handle return value of odp_queue_enq_multi()
Unsent packet has to be released. If the event type is obvious from the
context, use directly the relevant release functions, otherwise
odp_event_free().
Wider error handling is attempted, but this patch can't fix all the flaws
in the many calling functions of odp_queue_enq()
Signed-off-by: Zoltan Kiss <zoltan.kiss@linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'test/performance')
-rw-r--r-- | test/performance/odp_pktio_perf.c | 10 | ||||
-rw-r--r-- | test/performance/odp_scheduling.c | 8 |
2 files changed, 15 insertions, 3 deletions
diff --git a/test/performance/odp_pktio_perf.c b/test/performance/odp_pktio_perf.c index f4d9d2d2d..c2e95fb1e 100644 --- a/test/performance/odp_pktio_perf.c +++ b/test/performance/odp_pktio_perf.c @@ -270,12 +270,20 @@ static int alloc_packets(odp_event_t *event_tbl, int num_pkts) static int send_packets(odp_queue_t outq, odp_event_t *event_tbl, unsigned num_pkts) { + int ret; + unsigned i; + if (num_pkts == 0) return 0; else if (num_pkts == 1) return odp_queue_enq(outq, event_tbl[0]) == 0 ? 1 : 0; - return odp_queue_enq_multi(outq, event_tbl, num_pkts); + ret = odp_queue_enq_multi(outq, event_tbl, num_pkts); + i = ret < 0 ? 0 : ret; + for ( ; i < num_pkts; i++) + odp_event_free(event_tbl[i]); + return ret; + } /* diff --git a/test/performance/odp_scheduling.c b/test/performance/odp_scheduling.c index 99f0f9b05..a9ebfaa3e 100644 --- a/test/performance/odp_scheduling.c +++ b/test/performance/odp_scheduling.c @@ -530,9 +530,13 @@ static int test_schedule_multi(const char *str, int thr, } /* Assume we can enqueue all events */ - if (odp_queue_enq_multi(queue, ev, MULTI_BUFS_MAX) != - MULTI_BUFS_MAX) { + num = odp_queue_enq_multi(queue, ev, MULTI_BUFS_MAX); + if (num != MULTI_BUFS_MAX) { LOG_ERR(" [%i] Queue enqueue failed.\n", thr); + j = num < 0 ? 0 : num; + for ( ; j < MULTI_BUFS_MAX; j++) + odp_event_free(ev[j]); + return -1; } } |