Changeset 4530 for pjproject/trunk/pjsip/src/pjsip/sip_transport.c
- Timestamp:
- May 30, 2013 9:27:49 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip/sip_transport.c
r4529 r4530 93 93 pj_status_t (*on_tx_msg)(pjsip_endpoint*, pjsip_tx_data*); 94 94 pjsip_tp_state_callback tp_state_cb; 95 96 /* Transmit data list, for transmit data cleanup when transport manager 97 * is destroyed. 98 */ 99 pjsip_tx_data tdata_list; 95 100 }; 96 101 … … 420 425 421 426 pj_ioqueue_op_key_init(&tdata->op_key.key, sizeof(tdata->op_key.key)); 427 pj_list_init(tdata); 428 429 #if defined(PJSIP_HAS_TX_DATA_LIST) && PJSIP_HAS_TX_DATA_LIST!=0 430 /* Append this just created tdata to transmit buffer list */ 431 pj_lock_acquire(mgr->lock); 432 pj_list_push_back(&mgr->tdata_list, tdata); 433 pj_lock_release(mgr->lock); 434 #endif 422 435 423 436 #if defined(PJ_DEBUG) && PJ_DEBUG!=0 … … 438 451 } 439 452 453 static void tx_data_destroy(pjsip_tx_data *tdata) 454 { 455 PJ_LOG(5,(tdata->obj_name, "Destroying txdata %s", 456 pjsip_tx_data_get_info(tdata))); 457 pjsip_tpselector_dec_ref(&tdata->tp_sel); 458 #if defined(PJ_DEBUG) && PJ_DEBUG!=0 459 pj_atomic_dec( tdata->mgr->tdata_counter ); 460 #endif 461 462 #if defined(PJSIP_HAS_TX_DATA_LIST) && PJSIP_HAS_TX_DATA_LIST!=0 463 /* Remove this tdata from transmit buffer list */ 464 pj_lock_acquire(tdata->mgr->lock); 465 pj_list_erase(tdata); 466 pj_lock_release(tdata->mgr->lock); 467 #endif 468 469 pj_atomic_destroy( tdata->ref_cnt ); 470 pj_lock_destroy( tdata->lock ); 471 pjsip_endpt_release_pool( tdata->mgr->endpt, tdata->pool ); 472 } 473 440 474 /* 441 475 * Decrease transport data reference, destroy it when the reference count … … 446 480 pj_assert( pj_atomic_get(tdata->ref_cnt) > 0); 447 481 if (pj_atomic_dec_and_get(tdata->ref_cnt) <= 0) { 448 PJ_LOG(5,(tdata->obj_name, "Destroying txdata %s", 449 pjsip_tx_data_get_info(tdata))); 450 pjsip_tpselector_dec_ref(&tdata->tp_sel); 451 #if defined(PJ_DEBUG) && PJ_DEBUG!=0 452 pj_atomic_dec( tdata->mgr->tdata_counter ); 453 #endif 454 pj_atomic_destroy( tdata->ref_cnt ); 455 pj_lock_destroy( tdata->lock ); 456 pjsip_endpt_release_pool( tdata->mgr->endpt, tdata->pool ); 482 tx_data_destroy(tdata); 457 483 return PJSIP_EBUFDESTROYED; 458 484 } else { … … 1208 1234 mgr->on_tx_msg = tx_cb; 1209 1235 pj_list_init(&mgr->factory_list); 1236 pj_list_init(&mgr->tdata_list); 1210 1237 1211 1238 mgr->table = pj_hash_create(pool, PJSIP_TPMGR_HTABLE_SIZE); … … 1498 1525 1499 1526 pj_lock_release(mgr->lock); 1500 pj_lock_destroy(mgr->lock);1501 1502 /* Unregister mod_msg_print. */1503 if (mod_msg_print.id != -1) {1504 pjsip_endpt_unregister_module(endpt, &mod_msg_print);1505 }1506 1527 1507 1528 #if defined(PJ_DEBUG) && PJ_DEBUG!=0 … … 1518 1539 pj_atomic_destroy(mgr->tdata_counter); 1519 1540 #endif 1541 1542 /* 1543 * Destroy any dangling transmit buffer. 1544 */ 1545 if (!pj_list_empty(&mgr->tdata_list)) { 1546 pjsip_tx_data *tdata = mgr->tdata_list.next; 1547 while (tdata != &mgr->tdata_list) { 1548 pjsip_tx_data *next = tdata->next; 1549 tx_data_destroy(tdata); 1550 tdata = next; 1551 } 1552 PJ_LOG(3,(THIS_FILE, "Cleaned up dangling transmit buffer(s).")); 1553 } 1554 1555 pj_lock_destroy(mgr->lock); 1556 1557 /* Unregister mod_msg_print. */ 1558 if (mod_msg_print.id != -1) { 1559 pjsip_endpt_unregister_module(endpt, &mod_msg_print); 1560 } 1520 1561 1521 1562 return PJ_SUCCESS;
Note: See TracChangeset
for help on using the changeset viewer.