On Thu, Dec 18, 2014 at 10:27:43AM +0000, Taras Kondratiuk wrote:
> PKTIN queue was not handled correctly. Check queue status instead of
> queue type.
> 

I just had cause to want to destroy a PKTIN queue and remembered this
patch. I applied it and tested but get a SEGV in queue_deq_multi_destroy
when trying to free queue->s.sched_buf as it's ODP_BUFFER_INVALID, which
seems to be due to it being called twice for the same queue.

--
Stuart

> Reported-by: Stuart Haslam <[email protected]>
> Signed-off-by: Taras Kondratiuk <[email protected]>
> ---
>  platform/linux-generic/odp_queue.c | 39 
> ++++++++++++++++++++------------------
>  1 file changed, 21 insertions(+), 18 deletions(-)
> 
> diff --git a/platform/linux-generic/odp_queue.c 
> b/platform/linux-generic/odp_queue.c
> index 1462b41..c128aa0 100644
> --- a/platform/linux-generic/odp_queue.c
> +++ b/platform/linux-generic/odp_queue.c
> @@ -207,27 +207,30 @@ int odp_queue_destroy(odp_queue_t handle)
>       queue->s.enqueue = queue_enq_dummy;
>       queue->s.enqueue_multi = queue_enq_multi_dummy;
>  
> -     if (queue->s.type == ODP_QUEUE_TYPE_POLL ||
> -         queue->s.type == ODP_QUEUE_TYPE_PKTOUT) {
> +     switch (queue->s.status) {
> +     case QUEUE_STATUS_READY:
>               queue->s.status = QUEUE_STATUS_FREE;
>               queue->s.head = NULL;
>               queue->s.tail = NULL;
> -     } else if (queue->s.type == ODP_QUEUE_TYPE_SCHED) {
> -             if (queue->s.status == QUEUE_STATUS_SCHED)  {
> -                     /*
> -                      * Override dequeue_multi to destroy queue when it will
> -                      * be scheduled next time.
> -                      */
> -                     queue->s.status = QUEUE_STATUS_DESTROYED;
> -                     queue->s.dequeue_multi = queue_deq_multi_destroy;
> -             } else {
> -                     /* Queue won't be scheduled anymore */
> -                     odp_buffer_free(queue->s.sched_buf);
> -                     queue->s.sched_buf = ODP_BUFFER_INVALID;
> -                     queue->s.status = QUEUE_STATUS_FREE;
> -                     queue->s.head = NULL;
> -                     queue->s.tail = NULL;
> -             }
> +             break;
> +     case QUEUE_STATUS_SCHED:
> +             /*
> +              * Override dequeue_multi to destroy queue when it will
> +              * be scheduled next time.
> +              */
> +             queue->s.status = QUEUE_STATUS_DESTROYED;
> +             queue->s.dequeue_multi = queue_deq_multi_destroy;
> +             break;
> +     case QUEUE_STATUS_NOTSCHED:
> +             /* Queue won't be scheduled anymore */
> +             odp_buffer_free(queue->s.sched_buf);
> +             queue->s.sched_buf = ODP_BUFFER_INVALID;
> +             queue->s.status = QUEUE_STATUS_FREE;
> +             queue->s.head = NULL;
> +             queue->s.tail = NULL;
> +             break;
> +     default:
> +             ODP_ABORT("Unexpected queue status\n");
>       }
>       UNLOCK(&queue->s.lock);
>  
> -- 
> 1.9.1
> 
> 


_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to