Imported Upstream version 17.05.2
[deb_dpdk.git] / lib / librte_hash / rte_cuckoo_hash.c
index 51db006..37a8110 100644 (file)
@@ -536,9 +536,12 @@ __rte_hash_add_key_with_hash(const struct rte_hash *h, const void *key,
                if (cached_free_slots->len == 0) {
                        /* Need to get another burst of free slots from global ring */
                        n_slots = rte_ring_mc_dequeue_burst(h->free_slots,
-                                       cached_free_slots->objs, LCORE_CACHE_SIZE);
-                       if (n_slots == 0)
-                               return -ENOSPC;
+                                       cached_free_slots->objs,
+                                       LCORE_CACHE_SIZE, NULL);
+                       if (n_slots == 0) {
+                               ret = -ENOSPC;
+                               goto failure;
+                       }
 
                        cached_free_slots->len += n_slots;
                }
@@ -547,8 +550,10 @@ __rte_hash_add_key_with_hash(const struct rte_hash *h, const void *key,
                cached_free_slots->len--;
                slot_id = cached_free_slots->objs[cached_free_slots->len];
        } else {
-               if (rte_ring_sc_dequeue(h->free_slots, &slot_id) != 0)
-                       return -ENOSPC;
+               if (rte_ring_sc_dequeue(h->free_slots, &slot_id) != 0) {
+                       ret = -ENOSPC;
+                       goto failure;
+               }
        }
 
        new_k = RTE_PTR_ADD(keys, (uintptr_t)slot_id * h->key_entry_size);
@@ -658,6 +663,7 @@ __rte_hash_add_key_with_hash(const struct rte_hash *h, const void *key,
        /* 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:
        if (h->add_key == ADD_KEY_MULTIWRITER)
                rte_spinlock_unlock(h->multiwriter_lock);
        return ret;
@@ -808,7 +814,7 @@ remove_entry(const struct rte_hash *h, struct rte_hash_bucket *bkt, unsigned i)
                        /* Need to enqueue the free slots in global ring. */
                        n_slots = rte_ring_mp_enqueue_burst(h->free_slots,
                                                cached_free_slots->objs,
-                                               LCORE_CACHE_SIZE);
+                                               LCORE_CACHE_SIZE, NULL);
                        cached_free_slots->len -= n_slots;
                }
                /* Put index of new free slot in cache. */