浏览代码

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
Julien Chavanton 8 年之前
父节点
当前提交
0546af13b8
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      src/modules/dmq_usrloc/usrloc_sync.c

+ 2 - 2
src/modules/dmq_usrloc/usrloc_sync.c

@@ -62,8 +62,6 @@ static int add_contact(str aor, ucontact_info_t* ci)
 		return -1;
 		return -1;
 	}
 	}
 
 
-	dmq_ul.lock_udomain(_d, &aor);
-
 	LM_DBG("aor: %.*s\n", aor.len, aor.s);
 	LM_DBG("aor: %.*s\n", aor.len, aor.s);
 	LM_DBG("ci->ruid: %.*s\n", ci->ruid.len, ci->ruid.s);
 	LM_DBG("ci->ruid: %.*s\n", ci->ruid.len, ci->ruid.s);
 	LM_DBG("aorhash: %i\n", dmq_ul.get_aorhash(&aor));
 	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;
 			return 0;
 		}
 		}
 	}
 	}
+
+	dmq_ul.lock_udomain(_d, &aor);
 	res = dmq_ul.get_urecord(_d, &aor, &r);
 	res = dmq_ul.get_urecord(_d, &aor, &r);
 	if (res < 0) {
 	if (res < 0) {
 		LM_ERR("failed to retrieve record from usrloc\n");
 		LM_ERR("failed to retrieve record from usrloc\n");