X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_ring%2Frte_ring.c;h=6731d27c2069ec2f7685121634fc8af66d6fc53b;hb=782a303ddce843352686cccabbbf7e66a87519af;hp=2d6ed1f05d75998666e4fd1713c85d57bbf26d29;hpb=50d769054872d8c43e7cb66119e5387ca53deb90;p=dpdk.git diff --git a/lib/librte_ring/rte_ring.c b/lib/librte_ring/rte_ring.c index 2d6ed1f05d..6731d27c20 100644 --- a/lib/librte_ring/rte_ring.c +++ b/lib/librte_ring/rte_ring.c @@ -86,6 +86,7 @@ #include #include #include +#include #include "rte_ring.h" @@ -138,6 +139,8 @@ rte_ring_create(const char *name, unsigned count, int socket_id, rte_snprintf(mz_name, sizeof(mz_name), "RG_%s", name); ring_size = count * sizeof(void *) + sizeof(struct rte_ring); + rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK); + /* reserve a memory zone for this ring. If we can't get rte_config or * we are secondary process, the memzone_reserve function will set * rte_errno for us appropriately - hence no check in this this function */ @@ -162,6 +165,7 @@ rte_ring_create(const char *name, unsigned count, int socket_id, r = NULL; RTE_LOG(ERR, RING, "Cannot reserve memory\n"); } + rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK); return r; } @@ -252,9 +256,13 @@ rte_ring_list_dump(void) return; } + rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK); + TAILQ_FOREACH(mp, ring_list, next) { rte_ring_dump(mp); } + + rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK); } /* search a ring from its name */ @@ -271,11 +279,15 @@ rte_ring_lookup(const char *name) return NULL; } + rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK); + TAILQ_FOREACH(r, ring_list, next) { if (strncmp(name, r->name, RTE_RING_NAMESIZE) == 0) break; } + rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK); + if (r == NULL) rte_errno = ENOENT;