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-06 15:15:12 +0300 |
commit | 8235c6f0381a9c12fb4befe782b017ab4f2cebcb (patch) | |
tree | 08f1e90b96945400a18bb17c0e7753de1b95a48c /example | |
parent | 733cacfcfb3f31826022088abe9d7cf0c50e90d4 (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 ef95f95..99c61cb 100644 --- a/example/classifier/odp_classifier.c +++ b/example/classifier/odp_classifier.c @@ -298,7 +298,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 484e6bc..f92c565 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -414,6 +414,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 da88b17..b12ae56 100644 --- a/example/ipsec/odp_ipsec.c +++ b/example/ipsec/odp_ipsec.c @@ -1166,7 +1166,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; @@ -1184,8 +1185,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 a140d36..f533c40 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 7ff7d8f..83ea046 100644 --- a/example/packet/odp_pktio.c +++ b/example/packet/odp_pktio.c @@ -250,7 +250,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)) { |