115 lines
3.6 KiB
Diff
115 lines
3.6 KiB
Diff
From 552194179eb6deae8326eb0fef446e69240ea41b Mon Sep 17 00:00:00 2001
|
|
From: George Joseph <george.joseph@fairview5.com>
|
|
Date: Fri, 19 Feb 2016 17:05:53 -0700
|
|
Subject: [PATCH] sip_transport: Search for transport even if listener was
|
|
specified.
|
|
|
|
If a listener was specified when calling pjsip_tpmgr_acquire_transport2,
|
|
a new transport was always created instead of using an existing one. This
|
|
caused several issues mostly related to the remote end not expecting a new
|
|
connection. I.E. A TCP client who registered to a server is not going to
|
|
be listening for connections coming back from the server and refuses the
|
|
connection.
|
|
|
|
Now when pjsip_tpmgr_acquire_transport2 is called with a listener, the
|
|
registry is still searched for an existing transport and the listener
|
|
is used as a factory only if no existing transport can be found.
|
|
---
|
|
pjsip/src/pjsip/sip_transport.c | 68 ++++++++++++++++++++---------------------
|
|
1 file changed, 34 insertions(+), 34 deletions(-)
|
|
|
|
diff --git a/pjsip/src/pjsip/sip_transport.c b/pjsip/src/pjsip/sip_transport.c
|
|
index 0410324..620b9c0 100644
|
|
--- a/pjsip/src/pjsip/sip_transport.c
|
|
+++ b/pjsip/src/pjsip/sip_transport.c
|
|
@@ -1999,29 +1999,11 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,
|
|
|
|
TRACE_((THIS_FILE, "Transport %s acquired", seltp->obj_name));
|
|
return PJ_SUCCESS;
|
|
-
|
|
-
|
|
- } else if (sel && sel->type == PJSIP_TPSELECTOR_LISTENER &&
|
|
- sel->u.listener)
|
|
- {
|
|
- /* Application has requested that a specific listener is to
|
|
- * be used. In this case, skip transport hash table lookup.
|
|
- */
|
|
-
|
|
- /* Verify that the listener type matches the destination type */
|
|
- if (sel->u.listener->type != type) {
|
|
- pj_lock_release(mgr->lock);
|
|
- return PJSIP_ETPNOTSUITABLE;
|
|
- }
|
|
-
|
|
- /* We'll use this listener to create transport */
|
|
- factory = sel->u.listener;
|
|
-
|
|
} else {
|
|
|
|
/*
|
|
* This is the "normal" flow, where application doesn't specify
|
|
- * specific transport/listener to be used to send message to.
|
|
+ * specific transport to be used to send message to.
|
|
* In this case, lookup the transport from the hash table.
|
|
*/
|
|
pjsip_transport_key key;
|
|
@@ -2081,22 +2063,40 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,
|
|
return PJ_SUCCESS;
|
|
}
|
|
|
|
- /*
|
|
- * Transport not found!
|
|
- * Find factory that can create such transport.
|
|
- */
|
|
- factory = mgr->factory_list.next;
|
|
- while (factory != &mgr->factory_list) {
|
|
- if (factory->type == type)
|
|
- break;
|
|
- factory = factory->next;
|
|
- }
|
|
+ if (sel && sel->type == PJSIP_TPSELECTOR_LISTENER &&
|
|
+ sel->u.listener)
|
|
+ {
|
|
+ /* Application has requested that a specific listener is to
|
|
+ * be used.
|
|
+ */
|
|
+
|
|
+ /* Verify that the listener type matches the destination type */
|
|
+ if (sel->u.listener->type != type) {
|
|
+ pj_lock_release(mgr->lock);
|
|
+ return PJSIP_ETPNOTSUITABLE;
|
|
+ }
|
|
|
|
- if (factory == &mgr->factory_list) {
|
|
- /* No factory can create the transport! */
|
|
- pj_lock_release(mgr->lock);
|
|
- TRACE_((THIS_FILE, "No suitable factory was found either"));
|
|
- return PJSIP_EUNSUPTRANSPORT;
|
|
+ /* We'll use this listener to create transport */
|
|
+ factory = sel->u.listener;
|
|
+
|
|
+ } else {
|
|
+ /*
|
|
+ * Transport not found!
|
|
+ * Find factory that can create such transport.
|
|
+ */
|
|
+ factory = mgr->factory_list.next;
|
|
+ while (factory != &mgr->factory_list) {
|
|
+ if (factory->type == type)
|
|
+ break;
|
|
+ factory = factory->next;
|
|
+ }
|
|
+
|
|
+ if (factory == &mgr->factory_list) {
|
|
+ /* No factory can create the transport! */
|
|
+ pj_lock_release(mgr->lock);
|
|
+ TRACE_((THIS_FILE, "No suitable factory was found either"));
|
|
+ return PJSIP_EUNSUPTRANSPORT;
|
|
+ }
|
|
}
|
|
}
|
|
|
|
--
|
|
2.5.0
|
|
|