[asterisk-commits] res pjsip: Make aor named lock a mutex. (asterisk[master])
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Aug 11 23:27:16 CDT 2016
Anonymous Coward #1000019 has submitted this change and it was merged.
Change subject: res_pjsip: Make aor named lock a mutex.
......................................................................
res_pjsip: Make aor named lock a mutex.
The named aor lock was always being locked for writes so a rwlock adds no
benefit and may be slower because rwlocks are biased toward read locking.
Change-Id: I8c5c2c780eb30ce5441832257beeb3506fd12b28
---
M main/named_locks.c
M res/res_pjsip/location.c
M res/res_pjsip_registrar.c
M res/res_pjsip_registrar_expire.c
4 files changed, 10 insertions(+), 10 deletions(-)
Approvals:
Mark Michelson: Looks good to me, approved
George Joseph: Looks good to me, but someone else must approve
Anonymous Coward #1000019: Verified
Matt Jordan: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, approved
diff --git a/main/named_locks.c b/main/named_locks.c
index b977b55..5960483 100644
--- a/main/named_locks.c
+++ b/main/named_locks.c
@@ -87,8 +87,8 @@
int ast_named_locks_init(void)
{
- named_locks = ao2_container_alloc_hash(0, 0, NAMED_LOCKS_BUCKETS, named_locks_hash, NULL,
- named_locks_cmp);
+ named_locks = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0,
+ NAMED_LOCKS_BUCKETS, named_locks_hash, NULL, named_locks_cmp);
if (!named_locks) {
return -1;
}
diff --git a/res/res_pjsip/location.c b/res/res_pjsip/location.c
index 46278dd..c0c4a1f 100644
--- a/res/res_pjsip/location.c
+++ b/res/res_pjsip/location.c
@@ -209,12 +209,12 @@
struct ao2_container *contacts;
struct ast_named_lock *lock;
- lock = ast_named_lock_get(AST_NAMED_LOCK_TYPE_RWLOCK, "aor", ast_sorcery_object_get_id(aor));
+ lock = ast_named_lock_get(AST_NAMED_LOCK_TYPE_MUTEX, "aor", ast_sorcery_object_get_id(aor));
if (!lock) {
return NULL;
}
- ao2_wrlock(lock);
+ ao2_lock(lock);
contacts = ast_sip_location_retrieve_aor_contacts_nolock(aor);
ao2_unlock(lock);
ast_named_lock_put(lock);
@@ -368,12 +368,12 @@
int res;
struct ast_named_lock *lock;
- lock = ast_named_lock_get(AST_NAMED_LOCK_TYPE_RWLOCK, "aor", ast_sorcery_object_get_id(aor));
+ lock = ast_named_lock_get(AST_NAMED_LOCK_TYPE_MUTEX, "aor", ast_sorcery_object_get_id(aor));
if (!lock) {
return -1;
}
- ao2_wrlock(lock);
+ ao2_lock(lock);
res = ast_sip_location_add_contact_nolock(aor, uri, expiration_time, path_info, user_agent,
via_addr, via_port, call_id,
endpoint);
diff --git a/res/res_pjsip_registrar.c b/res/res_pjsip_registrar.c
index a39dac6..f99a3b8 100644
--- a/res/res_pjsip_registrar.c
+++ b/res/res_pjsip_registrar.c
@@ -525,12 +525,12 @@
struct ao2_container *contacts = NULL;
struct ast_named_lock *lock;
- lock = ast_named_lock_get(AST_NAMED_LOCK_TYPE_RWLOCK, "aor", aor_name);
+ lock = ast_named_lock_get(AST_NAMED_LOCK_TYPE_MUTEX, "aor", aor_name);
if (!lock) {
return PJ_TRUE;
}
- ao2_wrlock(lock);
+ ao2_lock(lock);
contacts = ast_sip_location_retrieve_aor_contacts_nolock(aor);
if (!contacts) {
ao2_unlock(lock);
diff --git a/res/res_pjsip_registrar_expire.c b/res/res_pjsip_registrar_expire.c
index 0d979a1..61841a0 100644
--- a/res/res_pjsip_registrar_expire.c
+++ b/res/res_pjsip_registrar_expire.c
@@ -44,7 +44,7 @@
struct ast_sip_contact *contact = obj;
struct ast_named_lock *lock;
- lock = ast_named_lock_get(AST_NAMED_LOCK_TYPE_RWLOCK, "aor", contact->aor);
+ lock = ast_named_lock_get(AST_NAMED_LOCK_TYPE_MUTEX, "aor", contact->aor);
if (!lock) {
return 0;
}
@@ -53,7 +53,7 @@
* We need to check the expiration again with the aor lock held
* in case another thread is attempting to renew the contact.
*/
- ao2_wrlock(lock);
+ ao2_lock(lock);
if (ast_tvdiff_ms(ast_tvnow(), contact->expiration_time) > 0) {
ast_sip_location_delete_contact(contact);
}
--
To view, visit https://gerrit.asterisk.org/3475
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8c5c2c780eb30ce5441832257beeb3506fd12b28
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>
More information about the asterisk-commits
mailing list