diff options
author | Zoltan Kiss <zoltan.kiss@linaro.org> | 2015-07-01 18:06:18 +0100 |
---|---|---|
committer | Maxim Uvarov <maxim.uvarov@linaro.org> | 2015-07-16 16:34:17 +0300 |
commit | 63754dbfa2e6263cfc3f5005a7bfec8dfca20dbf (patch) | |
tree | b69b0a27ffb6966a461269096002195b9ef342f1 /example | |
parent | 2e62eaca812e4d0194a2ca804a492ba03098cc67 (diff) |
queue: handle return value of odp_queue_enq()
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>
Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'example')
-rw-r--r-- | example/classifier/odp_classifier.c | 7 | ||||
-rw-r--r-- | example/generator/odp_generator.c | 1 | ||||
-rw-r--r-- | example/ipsec/odp_ipsec.c | 11 | ||||
-rw-r--r-- | example/ipsec/odp_ipsec_stream.c | 6 | ||||
-rw-r--r-- | example/packet/odp_pktio.c | 6 |
5 files changed, 25 insertions, 6 deletions
diff --git a/example/classifier/odp_classifier.c b/example/classifier/odp_classifier.c index 643e16c..7de11c6 100644 --- a/example/classifier/odp_classifier.c +++ b/example/classifier/odp_classifier.c @@ -294,7 +294,12 @@ static void *pktio_receive_thread(void *arg) if (appl->appl_mode == APPL_MODE_DROP) odp_packet_free(pkt); else - odp_queue_enq(outq_def, ev); + if (odp_queue_enq(outq_def, ev)) { + EXAMPLE_ERR(" [%i] Queue enqueue failed.\n", + thr); + odp_packet_free(pkt); + continue; + } } return NULL; diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index 15de035..d35f4aa 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -410,6 +410,7 @@ static void *gen_send_thread(void *arg) err = odp_queue_enq(outq_def, odp_packet_to_event(pkt)); if (err != 0) { EXAMPLE_ERR(" [%02i] send pkt err!\n", thr); + odp_packet_free(pkt); return NULL; } diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c index 4928985..089015f 100644 --- a/example/ipsec/odp_ipsec.c +++ b/example/ipsec/odp_ipsec.c @@ -1157,7 +1157,8 @@ void *pktio_thread(void *arg EXAMPLE_UNUSED) ctx->state = PKT_STATE_TRANSMIT; } else { ctx->state = PKT_STATE_IPSEC_OUT_SEQ; - odp_queue_enq(seqnumq, ev); + if (odp_queue_enq(seqnumq, ev)) + rc = PKT_DROP; } break; @@ -1175,8 +1176,12 @@ void *pktio_thread(void *arg EXAMPLE_UNUSED) case PKT_STATE_TRANSMIT: - odp_queue_enq(ctx->outq, ev); - rc = PKT_DONE; + if (odp_queue_enq(ctx->outq, ev)) { + odp_event_free(ev); + rc = PKT_DROP; + } else { + rc = PKT_DONE; + } break; default: diff --git a/example/ipsec/odp_ipsec_stream.c b/example/ipsec/odp_ipsec_stream.c index 9c4d682..8a1cc56 100644 --- a/example/ipsec/odp_ipsec_stream.c +++ b/example/ipsec/odp_ipsec_stream.c @@ -566,7 +566,11 @@ int create_stream_db_inputs(void) break; } stream->created++; - odp_queue_enq(queue, odp_packet_to_event(pkt)); + if (odp_queue_enq(queue, odp_packet_to_event(pkt))) { + odp_packet_free(pkt); + printf("Queue enqueue failed\n"); + break; + } /* Count this stream when we create first packet */ if (1 == stream->created) diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c index 0b4a8f1..8004d69 100644 --- a/example/packet/odp_pktio.c +++ b/example/packet/odp_pktio.c @@ -233,7 +233,11 @@ static void *pktio_queue_thread(void *arg) swap_pkt_addrs(&pkt, 1); /* Enqueue the packet for output */ - odp_queue_enq(outq_def, ev); + if (odp_queue_enq(outq_def, ev)) { + EXAMPLE_ERR(" [%i] Queue enqueue failed.\n", thr); + odp_packet_free(pkt); + continue; + } /* Print packet counts every once in a while */ if (odp_unlikely(pkt_cnt++ % 100000 == 0)) { |