Ignore:
Timestamp:
Mar 30, 2012 7:10:13 AM (12 years ago)
Author:
bennylp
Message:

Re #1474: Merged all changes from 1.12 - HEAD (from the 1.x branch)

Location:
pjproject/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk

  • pjproject/trunk/pjsip/src/pjsip/sip_endpoint.c

    r3753 r3999  
    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..")); 
     
    592608    /* Destroy timer heap */ 
    593609    pj_timer_heap_destroy(endpt->timer_heap); 
     610 
     611    /* Call all registered exit callbacks */ 
     612    ecb = endpt->exit_cb_list.next; 
     613    while (ecb != &endpt->exit_cb_list) { 
     614        (*ecb->func)(endpt); 
     615        ecb = ecb->next; 
     616    } 
    594617 
    595618    /* Delete endpoint mutex. */ 
     
    11831206} 
    11841207 
     1208 
     1209PJ_DEF(pj_status_t) pjsip_endpt_atexit( pjsip_endpoint *endpt, 
     1210                                        pjsip_endpt_exit_callback func) 
     1211{ 
     1212    exit_cb *new_cb; 
     1213 
     1214    PJ_ASSERT_RETURN(endpt && func, PJ_EINVAL); 
     1215 
     1216    new_cb = PJ_POOL_ZALLOC_T(endpt->pool, exit_cb); 
     1217    new_cb->func = func; 
     1218 
     1219    pj_mutex_lock(endpt->mutex); 
     1220    pj_list_push_back(&endpt->exit_cb_list, new_cb); 
     1221    pj_mutex_unlock(endpt->mutex); 
     1222 
     1223    return PJ_SUCCESS; 
     1224} 
Note: See TracChangeset for help on using the changeset viewer.