Changeset 4037


Ignore:
Timestamp:
Apr 11, 2012 9:41:25 AM (8 years ago)
Author:
bennylp
Message:

More re #1481: Destroying the regc may lead to dangling binding in the register, so instead of destroying the regc, instruct it to release the transport instead

Location:
pjproject/branches/1.x/pjsip
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/1.x/pjsip/include/pjsip-ua/sip_regc.h

    r3553 r4037  
    266266                                              const pjsip_tpselector *sel); 
    267267 
     268/** 
     269 * Release the reference to current transport being used by the regc, if any. 
     270 * The regc keeps the reference to the last transport being used in order 
     271 * to prevent it from being destroyed. In some situation however, such as 
     272 * when the transport is disconnected, it is necessary to instruct the 
     273 * regc to release this reference so that the transport can be destroyed. 
     274 * See https://trac.pjsip.org/repos/ticket/1481 for background info. 
     275 * 
     276 * @param regc      The client registration instance. 
     277 * 
     278 * @return          PJ_SUCCESS on success, or the appropriate error code. 
     279 */ 
     280PJ_DECL(pj_status_t) pjsip_regc_release_transport(pjsip_regc *regc); 
    268281 
    269282/** 
  • pjproject/branches/1.x/pjsip/src/pjsip-ua/sip_reg.c

    r3553 r4037  
    441441} 
    442442 
     443/* Release transport */ 
     444PJ_DEF(pj_status_t) pjsip_regc_release_transport(pjsip_regc *regc) 
     445{ 
     446    PJ_ASSERT_RETURN(regc, PJ_EINVAL); 
     447    if (regc->last_transport) { 
     448        pjsip_transport_dec_ref(regc->last_transport); 
     449        regc->last_transport = NULL; 
     450    } 
     451    return PJ_SUCCESS; 
     452} 
     453 
    443454 
    444455PJ_DEF(pj_status_t) pjsip_regc_add_headers( pjsip_regc *regc, 
     
    12701281 
    12711282    /* Get last transport used and add reference to it */ 
    1272     if (tdata->tp_info.transport != regc->last_transport) { 
     1283    if (tdata->tp_info.transport != regc->last_transport && 
     1284        status==PJ_SUCCESS) 
     1285    { 
    12731286        if (regc->last_transport) { 
    12741287            pjsip_transport_dec_ref(regc->last_transport); 
  • pjproject/branches/1.x/pjsip/src/pjsua-lib/pjsua_acc.c

    r4033 r4037  
    28222822        } 
    28232823 
    2824         /* Destroy regc to release transport immediately */ 
     2824        /* Release regc transport immediately 
     2825         * See https://trac.pjsip.org/repos/ticket/1481 
     2826         */ 
    28252827        if (pjsua_var.acc[i].regc) { 
    2826             pjsip_regc_destroy(pjsua_var.acc[i].regc); 
    2827         } 
    2828         pjsua_var.acc[i].regc = NULL; 
     2828            pjsip_regc_release_transport(pjsua_var.acc[i].regc); 
     2829        } 
    28292830 
    28302831        /* Schedule reregistration for this account */ 
Note: See TracChangeset for help on using the changeset viewer.