Changeset 6090
- Timestamp:
- Oct 11, 2019 2:23:03 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip/sip_transport.c
r6089 r6090 50 50 str, sizeof(str)); 51 51 return str; 52 } 53 static const char* print_tpsel_info(const pjsip_tpselector *sel) 54 { 55 static char tpsel_info_buf[80]; 56 if (!sel) return "(null)"; 57 if (sel->type==PJSIP_TPSELECTOR_LISTENER) 58 pj_ansi_snprintf(tpsel_info_buf, sizeof(tpsel_info_buf), 59 "listener[%s], reuse=%d", sel->u.listener->obj_name, 60 !sel->disable_connection_reuse); 61 else if (sel->type==PJSIP_TPSELECTOR_TRANSPORT) 62 pj_ansi_snprintf(tpsel_info_buf, sizeof(tpsel_info_buf), 63 "transport[%s], reuse=%d", sel->u.transport->info, 64 !sel->disable_connection_reuse); 65 else 66 pj_ansi_snprintf(tpsel_info_buf, sizeof(tpsel_info_buf), 67 "unknown[%p], reuse=%d", sel->u.ptr, 68 !sel->disable_connection_reuse); 69 return tpsel_info_buf; 52 70 } 53 71 #else … … 1226 1244 */ 1227 1245 pj_list_push_back(tp_ref, tp_add); 1246 TRACE_((THIS_FILE, "Remote address already registered, " 1247 "appended the transport to the list")); 1228 1248 } else { 1229 1249 /* Transport list not found, add it to the hash table. */ 1230 1250 pj_hash_set_np(mgr->table, &tp->key, key_len, hval, tp_add->tp_buf, 1231 1251 tp_add); 1252 TRACE_((THIS_FILE, "Remote address not registered, " 1253 "added the transport to the hash")); 1232 1254 } 1233 1255 … … 1299 1321 pj_hash_set_np(mgr->table, &tp_next->tp->key, key_len, 1300 1322 hval, tp_next->tp_buf, tp_next); 1323 TRACE_((THIS_FILE, "Hash entry updated after " 1324 "transport %d being destroyed", 1325 tp->obj_name)); 1326 } else { 1327 TRACE_((THIS_FILE, "Hash entry deleted after " 1328 "transport %d being destroyed", 1329 tp->obj_name)); 1301 1330 } 1302 1331 } … … 1310 1339 tp_iter = tp_iter->next; 1311 1340 } while (tp_iter != tp_ref); 1341 1342 if (tp_iter->tp != tp) { 1343 PJ_LOG(3, (THIS_FILE, "Warning: transport %s being destroyed is " 1344 "not registered", tp->obj_name)); 1345 } 1346 } else { 1347 PJ_LOG(3, (THIS_FILE, "Warning: transport %s being destroyed is " 1348 "not found in the hash table", tp->obj_name)); 1312 1349 } 1313 1350 … … 2175 2212 } 2176 2213 2214 2177 2215 /* 2178 2216 * pjsip_tpmgr_acquire_transport2() … … 2192 2230 pj_status_t status; 2193 2231 2194 TRACE_((THIS_FILE,"Acquiring transport type=%s, remote=%s:%d",2232 TRACE_((THIS_FILE,"Acquiring transport type=%s, sel=%s remote=%s:%d", 2195 2233 pjsip_transport_get_type_name(type), 2234 print_tpsel_info(sel), 2196 2235 addr_string(remote), 2197 2236 pj_sockaddr_get_port(remote))); … … 2210 2249 if (seltp->key.type != type) { 2211 2250 pj_lock_release(mgr->lock); 2251 TRACE_((THIS_FILE, "Transport type in tpsel not matched")); 2212 2252 return PJSIP_ETPNOTSUITABLE; 2213 2253 } … … 2250 2290 if (sel->u.listener->type != type) { 2251 2291 pj_lock_release(mgr->lock); 2292 TRACE_((THIS_FILE, "Listener type in tpsel not matched")); 2252 2293 return PJSIP_ETPNOTSUITABLE; 2253 2294 } … … 2265 2306 NULL); 2266 2307 if (tp_entry) { 2267 if (sel && sel->type == PJSIP_TPSELECTOR_LISTENER) { 2268 transport *tp_iter = tp_entry; 2269 do { 2308 transport *tp_iter = tp_entry; 2309 do { 2310 /* Don't use transport being shutdown */ 2311 if (!tp_iter->tp->is_shutdown) { 2270 2312 if (sel && sel->type == PJSIP_TPSELECTOR_LISTENER && 2271 sel->u.listener && 2272 tp_iter->tp->factory == sel->u.listener) 2313 sel->u.listener) 2273 2314 { 2315 /* Match listener if selector is set */ 2316 if (tp_iter->tp->factory == sel->u.listener) { 2317 tp_ref = tp_iter->tp; 2318 break; 2319 } 2320 } else { 2274 2321 tp_ref = tp_iter->tp; 2275 2322 break; 2276 2323 } 2277 tp_iter = tp_iter->next; 2278 } while (tp_iter != tp_entry); 2279 } else { 2280 tp_ref = tp_entry->tp; 2281 } 2324 } 2325 tp_iter = tp_iter->next; 2326 } while (tp_iter != tp_entry); 2282 2327 } 2283 2328 } … … 2292 2337 /* Ignore address for loop transports. */ 2293 2338 if (type == PJSIP_TRANSPORT_LOOP || 2294 2339 type == PJSIP_TRANSPORT_LOOP_DGRAM) 2295 2340 { 2296 2341 pj_sockaddr *addr = &key.rem_addr; … … 2331 2376 * but different factory). 2332 2377 */ 2378 TRACE_((THIS_FILE, "Transport found but from different listener")); 2333 2379 } 2334 2380 … … 2363 2409 2364 2410 /* Verify that the listener type matches the destination type */ 2411 /* Already checked above. */ 2412 /* 2365 2413 if (sel->u.listener->type != type) { 2366 2414 pj_lock_release(mgr->lock); 2367 2415 return PJSIP_ETPNOTSUITABLE; 2368 2416 } 2417 */ 2369 2418 2370 2419 /* We'll use this listener to create transport */
Note: See TracChangeset
for help on using the changeset viewer.