summaryrefslogtreecommitdiff
path: root/pjsip/src/pjsua-lib/pjsua_media.c
diff options
context:
space:
mode:
authorRiza Sulistyo <riza@teluu.com>2016-05-19 04:30:05 +0000
committerRiza Sulistyo <riza@teluu.com>2016-05-19 04:30:05 +0000
commit68958ad7d2304c6c78ca899ddb09827bcd993891 (patch)
tree8daac438d6612fcdb0087c0d0283298f530b853e /pjsip/src/pjsua-lib/pjsua_media.c
parent75e0e9499ed46428d7b07c7054c2f34f78a54437 (diff)
Re #1918: Fixed continous looping when trying to resolve STUN server due to lock handling.
Also move the unusable server to the least prioritize to be chosen on the fallback process. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@5307 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src/pjsua-lib/pjsua_media.c')
-rw-r--r--pjsip/src/pjsua-lib/pjsua_media.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/pjsip/src/pjsua-lib/pjsua_media.c b/pjsip/src/pjsua-lib/pjsua_media.c
index 7a8404c8..524915c7 100644
--- a/pjsip/src/pjsua-lib/pjsua_media.c
+++ b/pjsip/src/pjsua-lib/pjsua_media.c
@@ -393,11 +393,37 @@ static pj_status_t create_rtp_rtcp_sock(pjsua_call_media *call_med,
if (status != PJ_SUCCESS && pjsua_var.ua_cfg.stun_srv_cnt > 1 &&
((acc->cfg.media_stun_use & PJSUA_STUN_RETRY_ON_FAILURE)!=0))
{
- PJ_LOG(4,(THIS_FILE, "Failed to get STUN mapped address, "
- "retrying other STUN servers"));
+ pj_str_t srv =
+ pjsua_var.ua_cfg.stun_srv[pjsua_var.stun_srv_idx];
+
+ PJ_LOG(4,(THIS_FILE, "Failed to get STUN mapped address, "
+ "retrying other STUN servers"));
+
+ if (pjsua_var.stun_srv_idx < pjsua_var.ua_cfg.stun_srv_cnt-1) {
+ PJSUA_LOCK();
+ /* Move the unusable STUN server to the last position
+ * as the least prioritize.
+ */
+ pj_array_erase(pjsua_var.ua_cfg.stun_srv,
+ sizeof(pj_str_t),
+ pjsua_var.ua_cfg.stun_srv_cnt,
+ pjsua_var.stun_srv_idx);
+
+ pj_array_insert(pjsua_var.ua_cfg.stun_srv,
+ sizeof(pj_str_t),
+ pjsua_var.ua_cfg.stun_srv_cnt-1,
+ pjsua_var.ua_cfg.stun_srv_cnt-1,
+ &srv);
+
+ PJSUA_UNLOCK();
+ }
status=pjsua_update_stun_servers(pjsua_var.ua_cfg.stun_srv_cnt,
pjsua_var.ua_cfg.stun_srv,
- PJ_TRUE);
+ PJ_FALSE);
+
+ if (status == PJ_SUCCESS)
+ status = resolve_stun_server(PJ_TRUE);
+
if (status == PJ_SUCCESS) {
if (pjsua_var.stun_srv.addr.sa_family != 0) {
pj_ansi_strcpy(ip_addr,