* [dpdk-dev] [PATCH 5/6] rwlock not released when the key exists
@ 2017-08-18 20:21 mstolarchuk
0 siblings, 0 replies; only message in thread
From: mstolarchuk @ 2017-08-18 20:21 UTC (permalink / raw)
To: bruce.richardson, pablo.de.lara.guarch; +Cc: dev
Consisntly use a single exit path in the code,
have the various return values set 'ret' then use the single exit path.
Signed-off-by: mstolarchuk <mike.stolarchuk@bigswitch.com>
---
lib/librte_hash/rte_cuckoo_hash.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
index d1fbb0b..946252f 100644
--- a/lib/librte_hash/rte_cuckoo_hash.c
+++ b/lib/librte_hash/rte_cuckoo_hash.c
@@ -554,7 +554,7 @@ struct rte_hash *
LCORE_CACHE_SIZE, NULL);
if (n_slots == 0) {
ret = -ENOSPC;
- goto failure;
+ goto finished;
}
cached_free_slots->len += n_slots;
@@ -566,7 +566,7 @@ struct rte_hash *
} else {
if (rte_ring_sc_dequeue(h->free_slots, &slot_id) != 0) {
ret = -ENOSPC;
- goto failure;
+ goto finished;
}
}
@@ -588,7 +588,8 @@ struct rte_hash *
* Return index where key is stored,
* subtracting the first dummy index
*/
- return prim_bkt->key_idx[i] - 1;
+ ret = prim_bkt->key_idx[i] - 1;
+ goto finished;
}
}
}
@@ -607,7 +608,8 @@ struct rte_hash *
* Return index where key is stored,
* subtracting the first dummy index
*/
- return sec_bkt->key_idx[i] - 1;
+ ret = sec_bkt->key_idx[i] - 1;
+ goto finished;
}
}
}
@@ -649,9 +651,8 @@ struct rte_hash *
}
if (i != RTE_HASH_BUCKET_ENTRIES) {
- if (h->add_key == ADD_KEY_MULTIWRITER)
- rte_spinlock_unlock(h->multiwriter_lock);
- return new_idx - 1;
+ ret = new_idx - 1;
+ goto finished;
}
/* Primary bucket full, need to make space for new entry
@@ -665,9 +666,8 @@ struct rte_hash *
prim_bkt->sig_current[ret] = sig;
prim_bkt->sig_alt[ret] = alt_hash;
prim_bkt->key_idx[ret] = new_idx;
- if (h->add_key == ADD_KEY_MULTIWRITER)
- rte_spinlock_unlock(h->multiwriter_lock);
- return new_idx - 1;
+ ret = new_idx - 1;
+ goto finished;
}
#if defined(RTE_ARCH_X86)
}
@@ -675,7 +675,7 @@ struct rte_hash *
/* Error in addition, store new slot back in the ring and return error */
enqueue_slot_back(h, cached_free_slots, (void *)((uintptr_t) new_idx));
-failure:
+finished:
if (h->add_key == ADD_KEY_MULTIWRITER)
rte_spinlock_unlock(h->multiwriter_lock);
return ret;
--
1.9.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-08-18 20:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-18 20:21 [dpdk-dev] [PATCH 5/6] rwlock not released when the key exists mstolarchuk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).