Ignore:
Timestamp:
Mar 22, 2012 11:29:20 AM (12 years ago)
Author:
nanang
Message:

Close #1466 (using PJLIB outside PJSUA-LIB context):

  • static reference counter for PJLIB init/shutdown.
  • implemented atexit() in PJMEDIA and PJSIP level: pjmedia_endpt_atexit() & pjsip_endpt_atexit().
  • updated pjmedia/transport_srtp.c, pjsip/sip_timer.c, and pjsip/sip_replaces.c to use the new atexit() functions.
  • API change: pjmedia_srtp_init_lib() now requires 'pjmedia_endpt' param.
File:
1 edited

Legend:

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

    r3553 r3986  
    4141#define MAX_METHODS   32 
    4242 
     43 
     44/* List of SIP endpoint exit callback. */ 
     45typedef struct exit_cb 
     46{ 
     47    PJ_DECL_LIST_MEMBER             (struct exit_cb); 
     48    pjsip_endpt_exit_callback       func; 
     49} exit_cb; 
     50 
     51 
    4352/** 
    4453 * The SIP endpoint. 
     
    8796    /** Additional request headers. */ 
    8897    pjsip_hdr            req_hdr; 
     98 
     99    /** List of exit callback. */ 
     100    exit_cb              exit_cb_list; 
    89101}; 
    90102 
     
    446458    pj_list_init(&endpt->module_list); 
    447459 
     460    /* Initialize exit callback list. */ 
     461    pj_list_init(&endpt->exit_cb_list); 
     462 
    448463    /* Create R/W mutex for module manipulation. */ 
    449464    status = pj_rwmutex_create(endpt->pool, "ept%p", &endpt->mod_mutex); 
     
    560575{ 
    561576    pjsip_module *mod; 
     577    exit_cb *ecb; 
    562578 
    563579    PJ_LOG(5, (THIS_FILE, "Destroying endpoing instance..")); 
     580 
     581    /* Call all registered exit callbacks */ 
     582    ecb = endpt->exit_cb_list.next; 
     583    while (ecb != &endpt->exit_cb_list) { 
     584        (*ecb->func)(endpt); 
     585        ecb = ecb->next; 
     586    } 
    564587 
    565588    /* Phase 1: stop all modules */ 
     
    11791202} 
    11801203 
     1204 
     1205PJ_DEF(pj_status_t) pjsip_endpt_atexit( pjsip_endpoint *endpt, 
     1206                                        pjsip_endpt_exit_callback func) 
     1207{ 
     1208    exit_cb *new_cb; 
     1209 
     1210    PJ_ASSERT_RETURN(endpt && func, PJ_EINVAL); 
     1211 
     1212    new_cb = PJ_POOL_ZALLOC_T(endpt->pool, exit_cb); 
     1213    new_cb->func = func; 
     1214 
     1215    pj_mutex_lock(endpt->mutex); 
     1216    pj_list_push_back(&endpt->exit_cb_list, new_cb); 
     1217    pj_mutex_unlock(endpt->mutex); 
     1218 
     1219    return PJ_SUCCESS; 
     1220} 
Note: See TracChangeset for help on using the changeset viewer.