Changeset 3999 for pjproject/trunk/pjsip/src/pjsip/sip_endpoint.c
- Timestamp:
- Mar 30, 2012 7:10:13 AM (12 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk
-
pjproject/trunk/pjsip/src/pjsip/sip_endpoint.c
r3753 r3999 41 41 #define MAX_METHODS 32 42 42 43 44 /* List of SIP endpoint exit callback. */ 45 typedef struct exit_cb 46 { 47 PJ_DECL_LIST_MEMBER (struct exit_cb); 48 pjsip_endpt_exit_callback func; 49 } exit_cb; 50 51 43 52 /** 44 53 * The SIP endpoint. … … 87 96 /** Additional request headers. */ 88 97 pjsip_hdr req_hdr; 98 99 /** List of exit callback. */ 100 exit_cb exit_cb_list; 89 101 }; 90 102 … … 446 458 pj_list_init(&endpt->module_list); 447 459 460 /* Initialize exit callback list. */ 461 pj_list_init(&endpt->exit_cb_list); 462 448 463 /* Create R/W mutex for module manipulation. */ 449 464 status = pj_rwmutex_create(endpt->pool, "ept%p", &endpt->mod_mutex); … … 560 575 { 561 576 pjsip_module *mod; 577 exit_cb *ecb; 562 578 563 579 PJ_LOG(5, (THIS_FILE, "Destroying endpoing instance..")); … … 592 608 /* Destroy timer heap */ 593 609 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 } 594 617 595 618 /* Delete endpoint mutex. */ … … 1183 1206 } 1184 1207 1208 1209 PJ_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.