Changeset 2870 for pjproject/trunk


Ignore:
Timestamp:
Aug 12, 2009 7:04:02 PM (15 years ago)
Author:
nanang
Message:

Ticket #833: Updated Session Timer to keep the refresher role unchanged on any refreshes, by timer or manual.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsip-ua/sip_timer.c

    r2869 r2870  
    606606        pjsip_timer_init_session(inv, NULL); 
    607607 
     608    /* If refresher role (i.e: ours or peer) has been set/negotiated,  
     609     * better to keep it. 
     610     */ 
     611    if (inv->timer->refresher != TR_UNKNOWN) { 
     612        pj_bool_t as_refresher; 
     613 
     614        /* Check our refresher role */ 
     615        as_refresher =  
     616            (inv->timer->refresher==TR_UAC && inv->timer->role==PJSIP_ROLE_UAC) || 
     617            (inv->timer->refresher==TR_UAS && inv->timer->role==PJSIP_ROLE_UAS); 
     618 
     619        /* Update transaction role */ 
     620        inv->timer->role = PJSIP_ROLE_UAC; 
     621 
     622        /* Update refresher role */ 
     623        inv->timer->refresher = as_refresher? TR_UAC : TR_UAS; 
     624    } 
     625 
    608626    /* Add Session Timers headers */ 
    609627    add_timer_headers(inv, tdata, PJ_TRUE, PJ_TRUE); 
     
    879897    else if (se_hdr && pj_stricmp(&se_hdr->refresher, &STR_UAS) == 0) 
    880898        inv->timer->refresher = TR_UAS; 
    881     else 
    882         /* If UAC support timer (currently check the existance of  
    883          * Session-Expires header in the request), set UAC as refresher. 
     899    else { 
     900        /* If refresher role (i.e: ours or peer) has been set/negotiated,  
     901         * better to keep it. 
    884902         */ 
    885         inv->timer->refresher = se_hdr? TR_UAC : TR_UAS; 
     903        if (inv->timer->refresher != TR_UNKNOWN) { 
     904            pj_bool_t as_refresher; 
     905 
     906            /* Check our refresher role */ 
     907            as_refresher =  
     908                (inv->timer->refresher==TR_UAC && inv->timer->role==PJSIP_ROLE_UAC) || 
     909                (inv->timer->refresher==TR_UAS && inv->timer->role==PJSIP_ROLE_UAS); 
     910 
     911            /* Update refresher role */ 
     912            inv->timer->refresher = as_refresher? TR_UAS : TR_UAC; 
     913        } else { 
     914            /* If UAC support timer (currently check the existance of  
     915             * Session-Expires header in the request), set UAC as refresher. 
     916             */ 
     917            inv->timer->refresher = se_hdr? TR_UAC : TR_UAS; 
     918        } 
     919    } 
     920 
     921    /* Remember our role in this transaction */ 
     922    inv->timer->role = PJSIP_ROLE_UAS; 
    886923 
    887924    /* Set active flag */ 
     
    911948    { 
    912949        if (inv->timer && inv->timer->active) { 
    913             /* Remember our role in this transaction */ 
    914             inv->timer->role = PJSIP_ROLE_UAS; 
    915  
    916950            /* Add Session-Expires header and start the timer */ 
    917951            add_timer_headers(inv, tdata, PJ_TRUE, PJ_FALSE); 
Note: See TracChangeset for help on using the changeset viewer.