Changeset 5474 for pjproject


Ignore:
Timestamp:
Oct 28, 2016 3:57:55 AM (7 years ago)
Author:
ming
Message:

Re #1972: ICE initialization issues when creating a component/candidate fails.

Fixed ICE stuck if TURN creation fails in resolved state, assertions when trying to access other components/candidates, and crash when trying to access destroyed TURN socket.

Location:
pjproject/trunk/pjnath/src/pjnath
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjnath/src/pjnath/ice_strans.c

    r5465 r5474  
    165165    } turn[PJ_ICE_MAX_TURN]; 
    166166 
     167    pj_bool_t            creating;      /**< Is creating the candidates?*/ 
    167168    unsigned             cand_cnt;      /**< # of candidates/aliaes.    */ 
    168169    pj_ice_sess_cand     cand_list[PJ_ICE_ST_MAX_CAND]; /**< Cand array */ 
     
    666667    comp->ice_st = ice_st; 
    667668    comp->comp_id = comp_id; 
     669    comp->creating = PJ_TRUE; 
    668670 
    669671    ice_st->comp[comp_id-1] = comp; 
     
    693695        } 
    694696    } 
     697 
     698    /* Done creating all the candidates */ 
     699    comp->creating = PJ_FALSE; 
    695700 
    696701    /* It's possible that we end up without any candidates */ 
     
    933938        pj_ice_strans_comp *comp = ice_st->comp[i]; 
    934939 
     940        /* This function can be called when all components or candidates 
     941         * have not been created. 
     942         */ 
     943        if (!comp || comp->creating) return; 
     944 
    935945        for (j=0; j<comp->cand_cnt; ++j) { 
    936946            pj_ice_sess_cand *cand = &comp->cand_list[j]; 
     
    13081318            } 
    13091319 
    1310             if (count) { 
     1320            if (count && !comp->turn[n].err_cnt && comp->turn[n].sock) { 
    13111321                status = pj_turn_sock_set_perm(comp->turn[n].sock, count, 
    13121322                                               addrs, 0); 
     
    19902000        sess_init_update(comp->ice_st); 
    19912001 
    1992     } else if (old_state == PJ_TURN_STATE_RESOLVING && 
     2002    } else if ((old_state == PJ_TURN_STATE_RESOLVING || 
     2003                old_state == PJ_TURN_STATE_RESOLVED) && 
    19932004               new_state == PJ_TURN_STATE_DESTROYING) 
    19942005    { 
     
    19962007        unsigned i; 
    19972008 
    1998         /* DNS resolution has failed! */ 
     2009        /* DNS resolution or TURN transport creation/allocation 
     2010         * has failed. 
     2011         */ 
    19992012        ++comp->turn[tp_idx].err_cnt; 
    20002013 
     
    20152028            } 
    20162029        } 
    2017         pj_assert(cand != NULL); 
    20182030 
    20192031        pj_grp_lock_release(comp->ice_st->grp_lock); 
    20202032 
    2021         cand->status = PJ_ERESOLVE; 
     2033        /* If the error happens during pj_turn_sock_create() or 
     2034         * pj_turn_sock_alloc(), the candidate hasn't been added 
     2035         * to the list. 
     2036         */ 
     2037        if (cand) cand->status = PJ_ERESOLVE; 
    20222038 
    20232039        sess_init_update(comp->ice_st); 
  • pjproject/trunk/pjnath/src/pjnath/turn_sock.c

    r5380 r5474  
    891891            on_connect_complete(turn_sock->active_sock, PJ_SUCCESS); 
    892892        } else if (status != PJ_EPENDING) { 
     893            pj_perror(3, turn_sock->pool->obj_name, status, 
     894                      "Failed to connect to %s", 
     895                      pj_sockaddr_print(&info.server, addrtxt, 
     896                                        sizeof(addrtxt), 3)); 
    893897            pj_turn_sock_destroy(turn_sock); 
    894898            return; 
Note: See TracChangeset for help on using the changeset viewer.