Browse code

rtpengine: lock only when db backend is enabled for build_rtpp_socks()

Daniel-Constantin Mierla authored on 26/12/2018 10:50:50
Showing 1 changed files
... ...
@@ -1633,6 +1633,14 @@ mod_init(void)
1633 1633
 	return 0;
1634 1634
 }
1635 1635
 
1636
+#define rtpe_reload_lock_get(plock) do { \
1637
+	if (rtpp_db_url.s != NULL) lock_get(plock); \
1638
+} while(0)
1639
+
1640
+#define rtpe_reload_lock_release(plock) do { \
1641
+	if (rtpp_db_url.s != NULL) lock_release(plock); \
1642
+} while(0)
1643
+
1636 1644
 static int build_rtpp_socks() {
1637 1645
 	int n, i;
1638 1646
 	char *cp;
... ...
@@ -1644,9 +1652,9 @@ static int build_rtpp_socks() {
1644 1652
 	int ip_mtu_discover = IP_PMTUDISC_DONT;
1645 1653
 #endif
1646 1654
 
1647
-	lock_get(rtpp_no_lock);
1655
+	rtpe_reload_lock_get(rtpp_no_lock);
1648 1656
 	current_rtpp_no = *rtpp_no;
1649
-	lock_release(rtpp_no_lock);
1657
+	rtpe_reload_lock_release(rtpp_no_lock);
1650 1658
 
1651 1659
 	if (current_rtpp_no == rtpp_socks_size)
1652 1660
 		return 0;
... ...
@@ -1667,11 +1675,11 @@ static int build_rtpp_socks() {
1667 1675
 	}
1668 1676
 	memset(rtpp_socks, -1, sizeof(int)*(rtpp_socks_size));
1669 1677
 
1670
-	lock_get(rtpp_set_list->rset_head_lock);
1678
+	rtpe_reload_lock_get(rtpp_set_list->rset_head_lock);
1671 1679
 	for (rtpp_list = rtpp_set_list->rset_first; rtpp_list != 0;
1672 1680
 		rtpp_list = rtpp_list->rset_next) {
1673 1681
 
1674
-		lock_get(rtpp_list->rset_lock);
1682
+		rtpe_reload_lock_get(rtpp_list->rset_lock);
1675 1683
 		for (pnode=rtpp_list->rn_first; pnode!=0; pnode = pnode->rn_next) {
1676 1684
 			char *hostname;
1677 1685
 
... ...
@@ -1762,9 +1770,9 @@ static int build_rtpp_socks() {
1762 1770
 rptest:
1763 1771
 			pnode->rn_disabled = rtpp_test(pnode, 0, 1);
1764 1772
 		}
1765
-		lock_release(rtpp_list->rset_lock);
1773
+		rtpe_reload_lock_release(rtpp_list->rset_lock);
1766 1774
 	}
1767
-	lock_release(rtpp_set_list->rset_head_lock);
1775
+	rtpe_reload_lock_release(rtpp_set_list->rset_head_lock);
1768 1776
 
1769 1777
 	return 0;
1770 1778
 }