Changeset 4530 for pjproject/trunk
- Timestamp:
- May 30, 2013 9:27:49 AM (12 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsip/sip_config.h
r4506 r4530 1133 1133 1134 1134 1135 /** 1136 * Specify whether transport manager should maintain a list of transmit 1137 * buffer instances, so any possible dangling instance can be cleaned up 1138 * when the transport manager is shutdown (see also ticket #1671). 1139 * Note that this feature will have slight impact on the performance as 1140 * mutex is employed in updating the list, i.e: on creation and destruction 1141 * of transmit data. 1142 * 1143 * Default: 0 (no) 1144 */ 1145 #ifndef PJSIP_HAS_TX_DATA_LIST 1146 # define PJSIP_HAS_TX_DATA_LIST 0 1147 #endif 1148 1149 1135 1150 PJ_END_DECL 1136 1151 -
pjproject/trunk/pjsip/src/pjsip-simple/publishc.c
r4206 r4530 62 62 typedef struct pending_publish 63 63 { 64 PJ_DECL_LIST_MEMBER(pjsip_tx_data); 64 PJ_DECL_LIST_MEMBER(struct pending_publish); 65 pjsip_tx_data *tdata; 65 66 } pending_publish; 66 67 … … 109 110 /* Pending PUBLISH request */ 110 111 pending_publish pending_reqs; 112 pending_publish pending_reqs_empty; 111 113 }; 112 114 … … 181 183 pj_memcpy(&pubc->opt, opt, sizeof(*opt)); 182 184 pj_list_init(&pubc->pending_reqs); 185 pj_list_init(&pubc->pending_reqs_empty); 183 186 184 187 status = pj_mutex_create_recursive(pubc->pool, "pubc%p", &pubc->mutex); … … 684 687 pj_mutex_lock(pubc->mutex); 685 688 while (!pj_list_empty(&pubc->pending_reqs)) { 686 pjsip_tx_data *tdata = pubc->pending_reqs.next; 687 pj_list_erase(tdata); 689 pending_publish *pp = pubc->pending_reqs.next; 690 pjsip_tx_data *tdata = pp->tdata; 691 692 /* Remove the request from pending request list, 693 * and keep the unused entry into pending_reqs_empty pool. 694 */ 695 pj_list_erase(pp); 696 pj_list_push_back(&pubc->pending_reqs_empty, pp); 688 697 689 698 /* Add SIP-If-Match if we have etag and the request doesn't have … … 713 722 if (status == PJ_EPENDING) { 714 723 pj_assert(!"Not expected"); 715 pj_list_erase(tdata);716 724 pjsip_tx_data_dec_ref(tdata); 717 725 } else if (status == PJ_SUCCESS) { … … 745 753 if (pubc->pending_tsx) { 746 754 if (pubc->opt.queue_request) { 747 pj_list_push_back(&pubc->pending_reqs, tdata); 755 pending_publish *pp = NULL; 756 if (pj_list_empty(&pubc->pending_reqs_empty)) { 757 pp = PJ_POOL_ZALLOC_T(pubc->pool, pending_publish); 758 } else { 759 pp = pubc->pending_reqs_empty.next; 760 pj_list_erase(pp); 761 } 762 pp->tdata = tdata; 763 pj_list_push_back(&pubc->pending_reqs, pp); 748 764 pj_mutex_unlock(pubc->mutex); 749 765 PJ_LOG(4,(THIS_FILE, "Request is queued, pubc has another " -
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.