On Wed, Jun 03, 2015 at 07:06:01PM +0300, Maxim Uvarov wrote: > Use the right order in test: first lookup for pktio, > if it's not exist - create it. > > Signed-off-by: Maxim Uvarov <[email protected]> > --- > test/validation/odp_pktio.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/test/validation/odp_pktio.c b/test/validation/odp_pktio.c > index e1025d6..227ae83 100644 > --- a/test/validation/odp_pktio.c > +++ b/test/validation/odp_pktio.c > @@ -225,9 +225,9 @@ static odp_pktio_t create_pktio(const char *iface, int > num) > { > odp_pktio_t pktio; > > - pktio = odp_pktio_open(iface, pool[num]); > + pktio = odp_pktio_lookup(iface); > if (pktio == ODP_PKTIO_INVALID) > - pktio = odp_pktio_lookup(iface); > + pktio = odp_pktio_open(iface, pool[num]); > CU_ASSERT(pktio != ODP_PKTIO_INVALID); > CU_ASSERT(odp_pktio_to_u64(pktio) != > odp_pktio_to_u64(ODP_PKTIO_INVALID)); > -- > 1.9.1 >
Is how it is actually causing a problem? It was intentionally that way around to avoid a race condition, with the lookup->open sequence two threads may both fail on the lookup and then both call open and only one thread ends up with a valid handle. If they call open first, one will succeed and the other fails then calls lookup which should succeed so both threads get a valid handle. Granted this particular code is currently single threaded, but I prefer the open->lookup sequence generally. -- Stuart. _______________________________________________ lng-odp mailing list [email protected] https://lists.linaro.org/mailman/listinfo/lng-odp
