Message ID | 1428474470-30400-1-git-send-email-alexandru.badicioiu@linaro.org |
---|---|
State | Accepted |
Commit | 38dfc2770a0a8218d05c805faabd011d17a907fa |
Headers | show |
Merged, Maxim. On 04/08/15 09:27, alexandru.badicioiu@linaro.org wrote: > From: Alexandru Badicioiu <alexandru.badicioiu@linaro.org> > > Application should continue in case a packet context cannot be > allocated. > > Signed-off-by: Alexandru Badicioiu <alexandru.badicioiu@linaro.org> > --- > example/ipsec/odp_ipsec.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c > index 56e9aa8..0cbf5b4 100644 > --- a/example/ipsec/odp_ipsec.c > +++ b/example/ipsec/odp_ipsec.c > @@ -187,9 +187,8 @@ pkt_ctx_t *alloc_pkt_ctx(odp_packet_t pkt) > odp_buffer_t ctx_buf = odp_buffer_alloc(ctx_pool); > pkt_ctx_t *ctx; > > - /* There should always be enough contexts */ > if (odp_unlikely(ODP_BUFFER_INVALID == ctx_buf)) > - abort(); > + return NULL; > > ctx = odp_buffer_addr(ctx_buf); > memset(ctx, 0, sizeof(*ctx)); > @@ -1017,6 +1016,10 @@ void *pktio_thread(void *arg EXAMPLE_UNUSED) > ctx = get_pkt_ctx_from_pkt(pkt); > } else { > ctx = alloc_pkt_ctx(pkt); > + if (!ctx) { > + odp_packet_free(pkt); > + continue; > + } > ctx->state = PKT_STATE_INPUT_VERIFY; > } > } else if (ODP_EVENT_CRYPTO_COMPL == odp_event_type(ev)) {
diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c index 56e9aa8..0cbf5b4 100644 --- a/example/ipsec/odp_ipsec.c +++ b/example/ipsec/odp_ipsec.c @@ -187,9 +187,8 @@ pkt_ctx_t *alloc_pkt_ctx(odp_packet_t pkt) odp_buffer_t ctx_buf = odp_buffer_alloc(ctx_pool); pkt_ctx_t *ctx; - /* There should always be enough contexts */ if (odp_unlikely(ODP_BUFFER_INVALID == ctx_buf)) - abort(); + return NULL; ctx = odp_buffer_addr(ctx_buf); memset(ctx, 0, sizeof(*ctx)); @@ -1017,6 +1016,10 @@ void *pktio_thread(void *arg EXAMPLE_UNUSED) ctx = get_pkt_ctx_from_pkt(pkt); } else { ctx = alloc_pkt_ctx(pkt); + if (!ctx) { + odp_packet_free(pkt); + continue; + } ctx->state = PKT_STATE_INPUT_VERIFY; } } else if (ODP_EVENT_CRYPTO_COMPL == odp_event_type(ev)) {