- Timestamp:
- Jun 26, 2014 10:39:35 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip/sip_transport.c
r4802 r4865 78 78 }; 79 79 80 /* Transport list item */ 81 typedef struct transport 82 { 83 PJ_DECL_LIST_MEMBER(struct transport); 84 pjsip_transport *tp; 85 } transport; 86 80 87 /* 81 88 * Transport manager. … … 98 105 */ 99 106 pjsip_tx_data tdata_list; 107 108 /* List of transports which are NOT stored in the hash table, so 109 * that it can be properly cleaned up when transport manager 110 * is destroyed. 111 */ 112 transport tp_list; 100 113 }; 101 114 … … 1028 1041 hval = 0; 1029 1042 entry = pj_hash_get(mgr->table, &tp->key, key_len, &hval); 1030 if (entry != NULL) 1043 if (entry != NULL) { 1044 transport *tp_ref; 1045 1046 tp_ref = PJ_POOL_ZALLOC_T(((pjsip_transport *)entry)->pool, transport); 1047 1048 /* 1049 * Add transport to the list before removing it from the hash table. 1050 * See ticket #1774 for more details. 1051 */ 1052 tp_ref->tp = (pjsip_transport *)entry; 1053 pj_list_push_back(&mgr->tp_list, tp_ref); 1031 1054 pj_hash_set(NULL, mgr->table, &tp->key, key_len, hval, NULL); 1055 } 1032 1056 1033 1057 /* Register new entry */ … … 1075 1099 hval = 0; 1076 1100 entry = pj_hash_get(mgr->table, &tp->key, key_len, &hval); 1077 if (entry == (void*)tp) 1101 if (entry == (void*)tp) { 1078 1102 pj_hash_set(NULL, mgr->table, &tp->key, key_len, hval, NULL); 1103 } else { 1104 /* If not found in hash table, remove from the tranport list. */ 1105 transport *tp_iter = mgr->tp_list.next; 1106 while (tp_iter != &mgr->tp_list) { 1107 if (tp_iter->tp == tp) { 1108 pj_list_erase(tp_iter); 1109 break; 1110 } 1111 tp_iter = tp_iter->next; 1112 } 1113 } 1079 1114 1080 1115 pj_lock_release(mgr->lock); … … 1259 1294 pj_list_init(&mgr->factory_list); 1260 1295 pj_list_init(&mgr->tdata_list); 1296 pj_list_init(&mgr->tp_list); 1261 1297 1262 1298 mgr->table = pj_hash_create(pool, PJSIP_TPMGR_HTABLE_SIZE); … … 1527 1563 1528 1564 /* 1529 * Destroy all transports .1565 * Destroy all transports in the hash table. 1530 1566 */ 1531 1567 itr = pj_hash_first(mgr->table, &itr_val); … … 1543 1579 } 1544 1580 1581 /* 1582 * Destroy transports in the list. 1583 */ 1584 if (!pj_list_empty(&mgr->tp_list)) { 1585 transport *tp_iter = mgr->tp_list.next; 1586 while (tp_iter != &mgr->tp_list) { 1587 transport *next = tp_iter->next; 1588 destroy_transport(mgr, tp_iter->tp); 1589 tp_iter = next; 1590 } 1591 } 1592 1545 1593 /* 1546 1594 * Destroy all factories/listeners.
Note: See TracChangeset
for help on using the changeset viewer.