Skip to content
Snippets Groups Projects
Commit 0e90ddb7 authored by Guillaume Roguez's avatar Guillaume Roguez Committed by gerrit2
Browse files

turn: use official PJSIP patch to fix TURN

Commit 0bc5829b has introduced
a patch recently partialy integrated in PJSIP (see [1]).
But it doesn't take in account TURN error during ALLOCATING state.
This patch replace our patch by the PJSIP one and modify it
to handle the ALLOCATING case.

[1] https://trac.pjsip.org/repos/changeset/5465



Change-Id: Ic45458609e11b55641f13c3e6294eeda599d304e
Reviewed-by: default avatarStepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>
parent c1f2673a
No related branches found
No related tags found
No related merge requests found
...@@ -13,27 +13,41 @@ ...@@ -13,27 +13,41 @@
+ continue; + continue;
+ +
/* Gather remote addresses for this component */ /* Gather remote addresses for this component */
@@ -2013,4 +2016,21 @@ @@ -1995,4 +1998,37 @@
if (comp->ice_st->state < PJ_ICE_STRANS_STATE_READY) { sess_init_update(comp->ice_st);
- sess_fail(comp->ice_st, PJ_ICE_STRANS_OP_INIT,
- "TURN allocation failed", info.last_status); + } else if ((old_state == PJ_TURN_STATE_RESOLVING || old_state == PJ_TURN_STATE_ALLOCATING) &&
+ PJ_LOG(4,(comp->ice_st->obj_name, + new_state >= PJ_TURN_STATE_DEALLOCATING)
+ "TURN allocation failed, disable the associated candidate")); + {
+ pj_ice_sess_cand *cand = NULL; + pj_ice_sess_cand *cand = NULL;
+ unsigned i; + unsigned i;
+
+ /* DNS resolution has failed! */
+ ++comp->turn[tp_idx].err_cnt;
+
+ /* Unregister ourself from the TURN relay */
+ pj_turn_sock_set_user_data(turn_sock, NULL);
+ comp->turn[tp_idx].sock = NULL;
+
+ /* Wait until initialization completes */ + /* Wait until initialization completes */
+ pj_grp_lock_acquire(comp->ice_st->grp_lock); + pj_grp_lock_acquire(comp->ice_st->grp_lock);
+
+ /* Find relayed candidate in the component */ + /* Find relayed candidate in the component */
+ for (i=0; i<comp->cand_cnt; ++i) { + for (i=0; i<comp->cand_cnt; ++i) {
+ if (comp->cand_list[i].type == PJ_ICE_CAND_TYPE_RELAYED && + if (comp->cand_list[i].type == PJ_ICE_CAND_TYPE_RELAYED &&
+ comp->cand_list[i].transport_id == data->transport_id) { + comp->cand_list[i].transport_id == data->transport_id)
+ {
+ cand = &comp->cand_list[i]; + cand = &comp->cand_list[i];
+ break; + break;
+ } + }
+ } + }
+ pj_grp_lock_release(comp->ice_st->grp_lock);
+ pj_assert(cand != NULL); + pj_assert(cand != NULL);
+ // Make session init succeed but disable this TURN server to be used +
+ cand->status = PJNATH_ESTUNTIMEDOUT; + pj_grp_lock_release(comp->ice_st->grp_lock);
+
+ cand->status = old_state == PJ_TURN_STATE_RESOLVING ? PJ_ERESOLVE : PJ_EINVALIDOP;
+
+ sess_init_update(comp->ice_st); + sess_init_update(comp->ice_st);
} else if (comp->turn[tp_idx].err_cnt > 1) { +
} else if (new_state >= PJ_TURN_STATE_DEALLOCATING) {
pj_turn_session_info info;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment