ring: fix deadlock in zero object multi enqueue or dequeue
authorLazaros Koromilas <l@nofutznetworks.com>
Thu, 17 Mar 2016 15:49:43 +0000 (17:49 +0200)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Tue, 22 Mar 2016 16:55:16 +0000 (17:55 +0100)
commitd0979646166e740917baaabc4b78ded3482226b7
tree57d3cab6f9b9fff3a3ae858c74a16e8c6dd3d522
parent768f0e4587d17ba7c34aa47c9799c643c80d2585
ring: fix deadlock in zero object multi enqueue or dequeue

Issuing a zero objects dequeue with a single consumer has no effect.
Doing so with multiple consumers, can get more than one thread to succeed
the compare-and-set operation and observe starvation or even deadlock in
the while loop that checks for preceding dequeues.  The problematic piece
of code when n = 0:

    cons_next = cons_head + n;
    success = rte_atomic32_cmpset(&r->cons.head, cons_head, cons_next);

The same is possible on the enqueue path.

Fixes: af75078fece3 ("first public release")

Signed-off-by: Lazaros Koromilas <l@nofutznetworks.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
lib/librte_ring/rte_ring.h