[asterisk-commits] named locks: Use ao2 weakproxy find. (asterisk[master])
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Oct 12 10:16:45 CDT 2017
Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/6711 )
Change subject: named_locks: Use ao2_weakproxy_find.
......................................................................
named_locks: Use ao2_weakproxy_find.
Change-Id: I0ce8a1b7101b6caac6a19f83a89f00eaba1e9d9c
---
M main/named_locks.c
1 file changed, 7 insertions(+), 17 deletions(-)
Approvals:
Richard Mudgett: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved
Jenkins2: Approved for Submit
diff --git a/main/named_locks.c b/main/named_locks.c
index 27772f2..b38539c 100644
--- a/main/named_locks.c
+++ b/main/named_locks.c
@@ -108,31 +108,21 @@
struct ast_named_lock *__ast_named_lock_get(const char *filename, int lineno, const char *func,
enum ast_named_lock_type lock_type, const char *keyspace, const char *key)
{
- struct named_lock_proxy *proxy = NULL;
- struct ast_named_lock *lock = NULL;
+ struct named_lock_proxy *proxy;
+ struct ast_named_lock *lock;
int keylen = strlen(keyspace) + strlen(key) + 2;
char *concat_key = ast_alloca(keylen);
sprintf(concat_key, "%s-%s", keyspace, key); /* Safe */
ao2_lock(named_locks);
- proxy = ao2_find(named_locks, concat_key, OBJ_SEARCH_KEY | OBJ_NOLOCK);
- if (proxy) {
+ lock = __ao2_weakproxy_find(named_locks, concat_key, OBJ_SEARCH_KEY | OBJ_NOLOCK,
+ __PRETTY_FUNCTION__, filename, lineno, func);
+ if (lock) {
+ ast_assert((ao2_options_get(lock) & AO2_ALLOC_OPT_LOCK_MASK) == lock_type);
ao2_unlock(named_locks);
- lock = __ao2_weakproxy_get_object(proxy, 0, __PRETTY_FUNCTION__, filename, lineno, func);
- if (lock) {
- /* We have an existing lock and it's not being destroyed. */
- ao2_ref(proxy, -1);
- ast_assert((ao2_options_get(lock) & AO2_ALLOC_OPT_LOCK_MASK) == lock_type);
-
- return lock;
- }
-
- /* the old proxy is being destroyed, clean list before creating/adding new one */
- ao2_lock(named_locks);
- ao2_unlink_flags(named_locks, proxy, OBJ_NOLOCK);
- ao2_ref(proxy, -1);
+ return lock;
}
proxy = ao2_t_weakproxy_alloc(sizeof(*proxy) + keylen, NULL, concat_key);
--
To view, visit https://gerrit.asterisk.org/6711
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I0ce8a1b7101b6caac6a19f83a89f00eaba1e9d9c
Gerrit-Change-Number: 6711
Gerrit-PatchSet: 5
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-commits/attachments/20171012/1d9ac75b/attachment-0001.html>
More information about the asterisk-commits
mailing list