From: mstolarchuk <mike.stolarchuk@bigswitch.com>
To: bruce.richardson@intel.com, pablo.de.lara.guarch@intel.com
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 2/7] rwlock not released when the key exists
Date: Fri, 18 Aug 2017 13:16:17 -0700 [thread overview]
Message-ID: <1503087377-84633-1-git-send-email-mike.stolarchuk@bigswitch.com> (raw)
Consisntly use a single exit path in the code, have th various return values
set then call the exit path.
---
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..7606e3e 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
reply other threads:[~2017-08-18 20:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1503087377-84633-1-git-send-email-mike.stolarchuk@bigswitch.com \
--to=mike.stolarchuk@bigswitch.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=pablo.de.lara.guarch@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).