- Timestamp:
- Dec 28, 2016 3:40:07 AM (8 years ago)
- Location:
- pjproject/branches/projects/uwp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/uwp
- Property svn:mergeinfo changed
/pjproject/trunk (added) merged: 5209,5212-5234,5237-5253,5255,5257-5292,5294-5297,5299-5332,5334-5394,5396-5438,5440-5469,5471-5496,5498-5510
- Property svn:mergeinfo changed
-
pjproject/branches/projects/uwp/pjsip/src/pjsip/sip_transport.c
r5173 r5513 492 492 PJ_DEF(pj_status_t) pjsip_tx_data_dec_ref( pjsip_tx_data *tdata ) 493 493 { 494 pj_assert( pj_atomic_get(tdata->ref_cnt) > 0); 495 if (pj_atomic_dec_and_get(tdata->ref_cnt) <= 0) { 494 pj_atomic_value_t ref_cnt; 495 496 PJ_ASSERT_RETURN(tdata && tdata->ref_cnt, PJ_EINVAL); 497 498 ref_cnt = pj_atomic_dec_and_get(tdata->ref_cnt); 499 pj_assert( ref_cnt >= 0); 500 if (ref_cnt == 0) { 496 501 tx_data_destroy(tdata); 497 502 return PJSIP_EBUFDESTROYED; … … 1294 1299 { 1295 1300 pj_bzero(prm, sizeof(*prm)); 1301 } 1302 1303 static pj_bool_t pjsip_tpmgr_is_tpfactory_valid(pjsip_tpmgr *mgr, 1304 pjsip_tpfactory *tpf) 1305 { 1306 pjsip_tpfactory *p; 1307 1308 pj_lock_acquire(mgr->lock); 1309 for (p=mgr->factory_list.next; p!=&mgr->factory_list; p=p->next) { 1310 if (p == tpf) { 1311 pj_lock_release(mgr->lock); 1312 return PJ_TRUE; 1313 } 1314 } 1315 pj_lock_release(mgr->lock); 1316 1317 return PJ_FALSE; 1296 1318 } 1297 1319 … … 2001 2023 return PJ_SUCCESS; 2002 2024 2003 2004 } else if (sel && sel->type == PJSIP_TPSELECTOR_LISTENER &&2005 sel->u.listener)2006 {2007 /* Application has requested that a specific listener is to2008 * be used. In this case, skip transport hash table lookup.2009 */2010 2011 /* Verify that the listener type matches the destination type */2012 if (sel->u.listener->type != type) {2013 pj_lock_release(mgr->lock);2014 return PJSIP_ETPNOTSUITABLE;2015 }2016 2017 /* We'll use this listener to create transport */2018 factory = sel->u.listener;2019 2020 2025 } else { 2021 2026 2022 2027 /* 2023 2028 * This is the "normal" flow, where application doesn't specify 2024 * specific transport /listenerto be used to send message to.2029 * specific transport to be used to send message to. 2025 2030 * In this case, lookup the transport from the hash table. 2026 2031 */ … … 2028 2033 int key_len; 2029 2034 pjsip_transport *transport; 2035 2036 /* If listener is specified, verify that the listener type matches 2037 * the destination type. 2038 */ 2039 if (sel && sel->type == PJSIP_TPSELECTOR_LISTENER && sel->u.listener) 2040 { 2041 if (sel->u.listener->type != type) { 2042 pj_lock_release(mgr->lock); 2043 return PJSIP_ETPNOTSUITABLE; 2044 } 2045 } 2030 2046 2031 2047 pj_bzero(&key, sizeof(key)); … … 2070 2086 } 2071 2087 2088 /* If transport is found and listener is specified, verify listener */ 2089 else if (sel && sel->type == PJSIP_TPSELECTOR_LISTENER && 2090 sel->u.listener && transport->factory != sel->u.listener) 2091 { 2092 transport = NULL; 2093 /* This will cause a new transport to be created which will be a 2094 * 'duplicate' of the existing transport (same type & remote addr, 2095 * but different factory). Any future hash lookup will return 2096 * the new one, and eventually the old one will still be freed 2097 * (by application or #1774). 2098 */ 2099 } 2100 2072 2101 if (transport!=NULL && !transport->is_shutdown) { 2073 2102 /* … … 2082 2111 } 2083 2112 2113 2084 2114 /* 2085 2115 * Transport not found! 2086 * Find factory that can create such transport. 2116 * So we need to create one, find factory that can create 2117 * such transport. 2087 2118 */ 2088 factory = mgr->factory_list.next; 2089 while (factory != &mgr->factory_list) { 2090 if (factory->type == type) 2091 break; 2092 factory = factory->next; 2093 } 2094 2095 if (factory == &mgr->factory_list) { 2096 /* No factory can create the transport! */ 2097 pj_lock_release(mgr->lock); 2098 TRACE_((THIS_FILE, "No suitable factory was found either")); 2099 return PJSIP_EUNSUPTRANSPORT; 2119 if (sel && sel->type == PJSIP_TPSELECTOR_LISTENER && sel->u.listener) 2120 { 2121 /* Application has requested that a specific listener is to 2122 * be used. 2123 */ 2124 2125 /* Verify that the listener type matches the destination type */ 2126 if (sel->u.listener->type != type) { 2127 pj_lock_release(mgr->lock); 2128 return PJSIP_ETPNOTSUITABLE; 2129 } 2130 2131 /* We'll use this listener to create transport */ 2132 factory = sel->u.listener; 2133 2134 /* Verify if listener is still valid */ 2135 if (!pjsip_tpmgr_is_tpfactory_valid(mgr, factory)) { 2136 pj_lock_release(mgr->lock); 2137 PJ_LOG(3,(THIS_FILE, "Specified factory for creating " 2138 "transport is not found")); 2139 return PJ_ENOTFOUND; 2140 } 2141 2142 } else { 2143 2144 /* Find factory with type matches the destination type */ 2145 factory = mgr->factory_list.next; 2146 while (factory != &mgr->factory_list) { 2147 if (factory->type == type) 2148 break; 2149 factory = factory->next; 2150 } 2151 2152 if (factory == &mgr->factory_list) { 2153 /* No factory can create the transport! */ 2154 pj_lock_release(mgr->lock); 2155 TRACE_((THIS_FILE, "No suitable factory was found either")); 2156 return PJSIP_EUNSUPTRANSPORT; 2157 } 2100 2158 } 2101 2159 } … … 2117 2175 {pj_lock_release(mgr->lock); return PJ_EBUG;}); 2118 2176 pjsip_transport_add_ref(*tp); 2177 (*tp)->factory = factory; 2119 2178 } 2120 2179 pj_lock_release(mgr->lock);
Note: See TracChangeset
for help on using the changeset viewer.