Changeset 3989


Ignore:
Timestamp:
Mar 28, 2012 7:49:54 AM (7 years ago)
Author:
nanang
Message:

Fix #1470: Make sure the transaction layer module is unloaded when SIP endpoint is destroyed, by rescheduling the unload (using SIP endpoint atexit callback) after unload failure due to any pending/undestroyed transaction.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/1.x/pjsip/src/pjsip/sip_transaction.c

    r3924 r3989  
    715715 
    716716    pj_mutex_unlock(mod_tsx_layer.mutex); 
     717 
     718    PJ_LOG(4,(THIS_FILE, "Stopped transaction layer module")); 
     719 
    717720    return PJ_SUCCESS; 
     721} 
     722 
     723 
     724/* Destroy this module */ 
     725static void tsx_layer_destroy(pjsip_endpoint *endpt) 
     726{ 
     727    PJ_UNUSED_ARG(endpt); 
     728 
     729    /* Destroy mutex. */ 
     730    pj_mutex_destroy(mod_tsx_layer.mutex); 
     731 
     732    /* Release pool. */ 
     733    pjsip_endpt_release_pool(mod_tsx_layer.endpt, mod_tsx_layer.pool); 
     734 
     735    /* Free TLS */ 
     736    pj_thread_local_free(pjsip_tsx_lock_tls_id); 
     737 
     738    /* Mark as unregistered. */ 
     739    mod_tsx_layer.endpt = NULL; 
     740 
     741    PJ_LOG(4,(THIS_FILE, "Transaction layer module destroyed")); 
    718742} 
    719743 
     
    730754     * from transport and when it tries to unregister itself. 
    731755     */ 
    732     if (pj_hash_count(mod_tsx_layer.htable) != 0) 
     756    if (pj_hash_count(mod_tsx_layer.htable) != 0) { 
     757        if (pjsip_endpt_atexit(mod_tsx_layer.endpt, &tsx_layer_destroy) != 
     758            PJ_SUCCESS) 
     759        { 
     760            PJ_LOG(3,(THIS_FILE, "Failed to register transaction layer " 
     761                                 "module destroy.")); 
     762        } 
    733763        return PJ_EBUSY; 
    734  
    735     /* Destroy mutex. */ 
    736     pj_mutex_destroy(mod_tsx_layer.mutex); 
    737  
    738     /* Release pool. */ 
    739     pjsip_endpt_release_pool(mod_tsx_layer.endpt, mod_tsx_layer.pool); 
    740  
    741     /* Free TLS */ 
    742     pj_thread_local_free(pjsip_tsx_lock_tls_id); 
    743  
    744     /* Mark as unregistered. */ 
    745     mod_tsx_layer.endpt = NULL; 
    746  
    747     PJ_LOG(4,(THIS_FILE, "Transaction layer module destroyed")); 
     764    } 
     765 
     766    tsx_layer_destroy(mod_tsx_layer.endpt); 
    748767 
    749768    return PJ_SUCCESS; 
Note: See TracChangeset for help on using the changeset viewer.