From 0546af13b8e6e8e0255e1dc4ea406956913ec288 Mon Sep 17 00:00:00 2001 From: Julien Chavanton Date: Thu, 5 Jan 2017 10:32:31 -0500 Subject: [PATCH] dmq_usrloc: fix deadlock (#911) * dmq_usrloc: fix deadlock caused by acquiring the same lock twice using get_urecord_by_ruid and lock_udomain * dmq_usrloc: get_urecord_by_ruid returns with the lock if the record was found --- src/modules/dmq_usrloc/usrloc_sync.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/dmq_usrloc/usrloc_sync.c b/src/modules/dmq_usrloc/usrloc_sync.c index 9b966d5ae69..5a11e82970d 100644 --- a/src/modules/dmq_usrloc/usrloc_sync.c +++ b/src/modules/dmq_usrloc/usrloc_sync.c @@ -62,8 +62,6 @@ static int add_contact(str aor, ucontact_info_t* ci) return -1; } - dmq_ul.lock_udomain(_d, &aor); - LM_DBG("aor: %.*s\n", aor.len, aor.s); LM_DBG("ci->ruid: %.*s\n", ci->ruid.len, ci->ruid.s); LM_DBG("aorhash: %i\n", dmq_ul.get_aorhash(&aor)); @@ -81,6 +79,8 @@ static int add_contact(str aor, ucontact_info_t* ci) return 0; } } + + dmq_ul.lock_udomain(_d, &aor); res = dmq_ul.get_urecord(_d, &aor, &r); if (res < 0) { LM_ERR("failed to retrieve record from usrloc\n");