Merge "res_pjsip: Make aor named lock a mutex." into 13

This commit is contained in:
zuul
2016-08-11 23:14:38 -05:00
committed by Gerrit Code Review
4 changed files with 10 additions and 10 deletions

View File

@@ -87,8 +87,8 @@ static void named_locks_shutdown(void)
int ast_named_locks_init(void) int ast_named_locks_init(void)
{ {
named_locks = ao2_container_alloc_hash(0, 0, NAMED_LOCKS_BUCKETS, named_locks_hash, NULL, named_locks = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0,
named_locks_cmp); NAMED_LOCKS_BUCKETS, named_locks_hash, NULL, named_locks_cmp);
if (!named_locks) { if (!named_locks) {
return -1; return -1;
} }

View File

@@ -214,12 +214,12 @@ struct ao2_container *ast_sip_location_retrieve_aor_contacts(const struct ast_si
struct ao2_container *contacts; struct ao2_container *contacts;
struct ast_named_lock *lock; 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) { if (!lock) {
return NULL; return NULL;
} }
ao2_wrlock(lock); ao2_lock(lock);
contacts = ast_sip_location_retrieve_aor_contacts_nolock(aor); contacts = ast_sip_location_retrieve_aor_contacts_nolock(aor);
ao2_unlock(lock); ao2_unlock(lock);
ast_named_lock_put(lock); ast_named_lock_put(lock);
@@ -373,12 +373,12 @@ int ast_sip_location_add_contact(struct ast_sip_aor *aor, const char *uri,
int res; int res;
struct ast_named_lock *lock; 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) { if (!lock) {
return -1; return -1;
} }
ao2_wrlock(lock); ao2_lock(lock);
res = ast_sip_location_add_contact_nolock(aor, uri, expiration_time, path_info, user_agent, res = ast_sip_location_add_contact_nolock(aor, uri, expiration_time, path_info, user_agent,
via_addr, via_port, call_id, via_addr, via_port, call_id,
endpoint); endpoint);

View File

@@ -525,12 +525,12 @@ static int register_aor(pjsip_rx_data *rdata,
struct ao2_container *contacts = NULL; struct ao2_container *contacts = NULL;
struct ast_named_lock *lock; 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) { if (!lock) {
return PJ_TRUE; return PJ_TRUE;
} }
ao2_wrlock(lock); ao2_lock(lock);
contacts = ast_sip_location_retrieve_aor_contacts_nolock(aor); contacts = ast_sip_location_retrieve_aor_contacts_nolock(aor);
if (!contacts) { if (!contacts) {
ao2_unlock(lock); ao2_unlock(lock);

View File

@@ -44,7 +44,7 @@ static int expire_contact(void *obj, void *arg, int flags)
struct ast_sip_contact *contact = obj; struct ast_sip_contact *contact = obj;
struct ast_named_lock *lock; 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) { if (!lock) {
return 0; return 0;
} }
@@ -53,7 +53,7 @@ static int expire_contact(void *obj, void *arg, int flags)
* We need to check the expiration again with the aor lock held * We need to check the expiration again with the aor lock held
* in case another thread is attempting to renew the contact. * 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) { if (ast_tvdiff_ms(ast_tvnow(), contact->expiration_time) > 0) {
ast_sip_location_delete_contact(contact); ast_sip_location_delete_contact(contact);
} }