Changeset 3022


Ignore:
Timestamp:
Nov 23, 2009 3:02:18 PM (15 years ago)
Author:
bennylp
Message:

More #953 (ICE may find the wrong best candidate):

  • the sorting process may cause valid checks to point to the wrong candidate pair. This is reproducible by pjnath-test
File:
1 edited

Legend:

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

    r3005 r3022  
    950950 
    951951/* Sort checklist based on priority */ 
    952 static void sort_checklist(pj_ice_sess_checklist *clist) 
     952static void sort_checklist(pj_ice_sess *ice, pj_ice_sess_checklist *clist) 
    953953{ 
    954954    unsigned i; 
     955    pj_ice_sess_check **check_ptr[PJ_ICE_MAX_COMP*2]; 
     956    unsigned check_ptr_cnt = 0; 
     957 
     958    for (i=0; i<ice->comp_cnt; ++i) { 
     959        if (ice->comp[i].valid_check) { 
     960            check_ptr[check_ptr_cnt++] = &ice->comp[i].valid_check; 
     961        } 
     962        if (ice->comp[i].nominated_check) { 
     963            check_ptr[check_ptr_cnt++] = &ice->comp[i].nominated_check; 
     964        } 
     965    } 
    955966 
    956967    for (i=0; i<clist->count-1; ++i) { 
    957968        unsigned j, highest = i; 
     969 
    958970        for (j=i+1; j<clist->count; ++j) { 
    959971            if (CMP_CHECK_PRIO(&clist->checks[j], &clist->checks[highest]) > 0) { 
     
    964976        if (highest != i) { 
    965977            pj_ice_sess_check tmp; 
     978            unsigned k; 
    966979 
    967980            pj_memcpy(&tmp, &clist->checks[i], sizeof(pj_ice_sess_check)); 
     
    970983            pj_memcpy(&clist->checks[highest], &tmp,  
    971984                      sizeof(pj_ice_sess_check)); 
     985 
     986            /* Update valid and nominated check pointers, since we're moving 
     987             * around checks 
     988             */ 
     989            for (k=0; k<check_ptr_cnt; ++k) { 
     990                if (*check_ptr[k] == &clist->checks[highest]) 
     991                    *check_ptr[k] = &clist->checks[i]; 
     992                else if (*check_ptr[k] == &clist->checks[i]) 
     993                    *check_ptr[k] = &clist->checks[highest]; 
     994            } 
    972995        } 
    973996    } 
     
    16671690 
    16681691    /* Sort checklist based on priority */ 
    1669     sort_checklist(clist); 
     1692    sort_checklist(ice, clist); 
    16701693 
    16711694    /* Prune the checklist */ 
     
    23352358     * new_check will point to something else (#953) 
    23362359     */ 
    2337     sort_checklist(&ice->valid_list); 
     2360    sort_checklist(ice, &ice->valid_list); 
    23382361 
    23392362    /* 7.1.2.2.2.  Updating Pair States 
Note: See TracChangeset for help on using the changeset viewer.