[Asterisk-code-review] res pjsip sdp rtp.c: Don't use deprecated transport struct m... (asterisk[14])

Joshua Colp asteriskteam at digium.com
Wed Apr 12 04:53:41 CDT 2017


Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/5437 )

Change subject: res_pjsip_sdp_rtp.c: Don't use deprecated transport struct member.
......................................................................


res_pjsip_sdp_rtp.c: Don't use deprecated transport struct member.

* create_rtp(): Eliminate use of deprecated transport struct member.  That
member and several others in the transport structure were deprecated
because of an infinite loop created when using realtime configuration.
See 2451d4e4550336197ee2e482750cc53f30afa352

ASTERISK-26851

Change-Id: I0533aa13c9ce3c6cc394e0fd2b5bf1cd1b2ef3bc
---
M res/res_pjsip_sdp_rtp.c
1 file changed, 20 insertions(+), 14 deletions(-)

Approvals:
  George Joseph: Looks good to me, approved
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, but someone else must approve



diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c
index cbb2bef..ddcdb8a 100644
--- a/res/res_pjsip_sdp_rtp.c
+++ b/res/res_pjsip_sdp_rtp.c
@@ -210,24 +210,30 @@
 				session->endpoint->media.address);
 		}
 	} else {
-		struct ast_sip_transport *transport =
-			ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "transport",
-									   session->endpoint->transport);
+		struct ast_sip_transport *transport;
 
-		if (transport && transport->state) {
-			char hoststr[PJ_INET6_ADDRSTRLEN];
+		transport = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "transport",
+			session->endpoint->transport);
+		if (transport) {
+			struct ast_sip_transport_state *trans_state;
 
-			pj_sockaddr_print(&transport->state->host, hoststr, sizeof(hoststr), 0);
-			if (ast_sockaddr_parse(&temp_media_address, hoststr, 0)) {
-				ast_debug(1, "Transport %s bound to %s: Using it for RTP media.\n",
-					session->endpoint->transport, hoststr);
-				media_address = &temp_media_address;
-			} else {
-				ast_debug(1, "Transport %s bound to %s: Invalid for RTP media.\n",
-					session->endpoint->transport, hoststr);
+			trans_state = ast_sip_get_transport_state(ast_sorcery_object_get_id(transport));
+			if (trans_state) {
+				char hoststr[PJ_INET6_ADDRSTRLEN];
+
+				pj_sockaddr_print(&trans_state->host, hoststr, sizeof(hoststr), 0);
+				if (ast_sockaddr_parse(&temp_media_address, hoststr, 0)) {
+					ast_debug(1, "Transport %s bound to %s: Using it for RTP media.\n",
+						session->endpoint->transport, hoststr);
+					media_address = &temp_media_address;
+				} else {
+					ast_debug(1, "Transport %s bound to %s: Invalid for RTP media.\n",
+						session->endpoint->transport, hoststr);
+				}
+				ao2_ref(trans_state, -1);
 			}
+			ao2_ref(transport, -1);
 		}
-		ao2_cleanup(transport);
 	}
 
 	if (!(session_media->rtp = ast_rtp_instance_new(session->endpoint->media.rtp.engine, sched, media_address, NULL))) {

-- 
To view, visit https://gerrit.asterisk.org/5437
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I0533aa13c9ce3c6cc394e0fd2b5bf1cd1b2ef3bc
Gerrit-PatchSet: 2
Gerrit-Project: asterisk
Gerrit-Branch: 14
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>



More information about the asterisk-code-review mailing list