mirror of https://github.com/sipwise/kamailio.git
Change-Id: I91d551a68ebaa28af0c1c13f55b67983cd11cdbbchanges/23/11123/3
parent
446d2621eb
commit
37a79ead36
@ -0,0 +1,126 @@
|
||||
--- a/modules/rtpengine/rtpengine.c
|
||||
+++ b/modules/rtpengine/rtpengine.c
|
||||
@@ -195,7 +195,7 @@
|
||||
static struct rtpp_node *select_rtpp_node_old(str, str, int, enum rtpe_operation);
|
||||
static struct rtpp_node *select_rtpp_node(str, str, int, struct rtpp_node **, int, enum rtpe_operation);
|
||||
static int is_queried_node(struct rtpp_node *, struct rtpp_node **, int);
|
||||
-static int build_rtpp_socks(unsigned int current_rtpp_no);
|
||||
+static int build_rtpp_socks();
|
||||
static char *send_rtpp_command(struct rtpp_node *, bencode_item_t *, int *);
|
||||
static int get_extra_id(struct sip_msg* msg, str *id_str);
|
||||
|
||||
@@ -1069,6 +1069,9 @@
|
||||
str rtpp_url;
|
||||
str snode, sattr, svalue;
|
||||
|
||||
+ if (build_rtpp_socks())
|
||||
+ return init_mi_tree(400, MI_DB_ERR, MI_DB_ERR_LEN);
|
||||
+
|
||||
found = MI_FOUND_NONE;
|
||||
found_rtpp_disabled = 0;
|
||||
found_rtpp = NULL;
|
||||
@@ -1413,6 +1416,9 @@
|
||||
str rtpp_url;
|
||||
str snode, sattr, svalue;
|
||||
|
||||
+ if (build_rtpp_socks())
|
||||
+ return init_mi_tree(400, MI_DB_ERR, MI_DB_ERR_LEN);
|
||||
+
|
||||
found = 0;
|
||||
found_rtpp_disabled = 0;
|
||||
found_rtpp = NULL;
|
||||
@@ -1577,7 +1583,6 @@
|
||||
mi_reload_rtp_proxy(struct mi_root* cmd_tree, void* param)
|
||||
{
|
||||
struct mi_root *root = NULL;
|
||||
- unsigned int current_rtpp_no;
|
||||
|
||||
if (rtpp_db_url.s == NULL) {
|
||||
// no database
|
||||
@@ -1595,13 +1600,7 @@
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
- lock_get(rtpp_no_lock);
|
||||
- current_rtpp_no = *rtpp_no;
|
||||
- lock_release(rtpp_no_lock);
|
||||
-
|
||||
- if (rtpp_socks_size != current_rtpp_no) {
|
||||
- build_rtpp_socks(current_rtpp_no);
|
||||
- }
|
||||
+ build_rtpp_socks();
|
||||
|
||||
// success reloading from database
|
||||
root = init_mi_tree(200, MI_DB_OK, MI_DB_OK_LEN);
|
||||
@@ -1796,16 +1795,24 @@
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static int build_rtpp_socks(unsigned int current_rtpp_no) {
|
||||
+static int build_rtpp_socks() {
|
||||
int n, i;
|
||||
char *cp;
|
||||
struct addrinfo hints, *res;
|
||||
struct rtpp_set *rtpp_list;
|
||||
struct rtpp_node *pnode;
|
||||
+ unsigned int current_rtpp_no;
|
||||
#ifdef IP_MTU_DISCOVER
|
||||
int ip_mtu_discover = IP_PMTUDISC_DONT;
|
||||
#endif
|
||||
|
||||
+ lock_get(rtpp_no_lock);
|
||||
+ current_rtpp_no = *rtpp_no;
|
||||
+ lock_release(rtpp_no_lock);
|
||||
+
|
||||
+ if (current_rtpp_no == rtpp_socks_size)
|
||||
+ return 0;
|
||||
+
|
||||
// close current sockets
|
||||
for (i = 0; i < rtpp_socks_size; i++) {
|
||||
if (rtpp_socks[i] >= 0) {
|
||||
@@ -1921,16 +1928,6 @@
|
||||
|
||||
mypid = getpid();
|
||||
|
||||
- lock_get(rtpp_no_lock);
|
||||
- rtpp_socks_size = *rtpp_no;
|
||||
- lock_release(rtpp_no_lock);
|
||||
-
|
||||
- rtpp_socks = (int*)pkg_malloc(sizeof(int)*(rtpp_socks_size));
|
||||
- if (!rtpp_socks) {
|
||||
- return -1;
|
||||
- }
|
||||
- memset(rtpp_socks, -1, sizeof(int)*(rtpp_socks_size));
|
||||
-
|
||||
// vector of pointers to queried nodes
|
||||
queried_nodes_ptr = (struct rtpp_node**)pkg_malloc(queried_nodes_limit * sizeof(struct rtpp_node*));
|
||||
if (!queried_nodes_ptr) {
|
||||
@@ -1940,9 +1937,8 @@
|
||||
memset(queried_nodes_ptr, 0, queried_nodes_limit * sizeof(struct rtpp_node*));
|
||||
|
||||
/* Iterate known RTP proxies - create sockets */
|
||||
- if (rtpp_socks_size) {
|
||||
- build_rtpp_socks(rtpp_socks_size);
|
||||
- }
|
||||
+ if (build_rtpp_socks())
|
||||
+ return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -2867,15 +2863,8 @@
|
||||
select_rtpp_node(str callid, str viabranch, int do_test, struct rtpp_node **queried_nodes_ptr, int queried_nodes, enum rtpe_operation op)
|
||||
{
|
||||
struct rtpp_node *node = NULL;
|
||||
- unsigned int current_rtpp_no;
|
||||
|
||||
- lock_get(rtpp_no_lock);
|
||||
- current_rtpp_no = *rtpp_no;
|
||||
- lock_release(rtpp_no_lock);
|
||||
-
|
||||
- if (rtpp_socks_size != current_rtpp_no) {
|
||||
- build_rtpp_socks(current_rtpp_no);
|
||||
- }
|
||||
+ build_rtpp_socks();
|
||||
|
||||
if (!active_rtpp_set) {
|
||||
default_rtpp_set = select_rtpp_set(setid_default);
|
Loading…
Reference in new issue