From 2451d4e4550336197ee2e482750cc53f30afa352 Mon Sep 17 00:00:00 2001 From: George Joseph Date: Fri, 29 Jan 2016 16:56:42 -0700 Subject: res_pjsip: Fix infinite recursion when loading transports from realtime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Attempting to load a transport from realtime was forcing asterisk into an infinite recursion loop. The first thing transport_apply did was to do a sorcery retrieve by id for an existing transport of the same name. For files, this just returns the previous object from res_sorcery_config's internal container, if any. For realtime, the res_sourcery_realtime driver looks in the database and finds the existing row but now it has to rehydrate it into a sorcery object which means calling... transport_apply. And so it goes. The main issue with loading from realtime (apart from the loop) was that transport stores structures and pointers directly in the ast_sip_transport structure instead of the separate ast_transport_state structure. This patch separates those items into the ast_sip_transport_state structure. The pattern is roughly the same as res_pjsip_outbound_registration. Although all current usages of ast_sip_transport and ast_sip_transport_state were modified to use the new ast_sip_get_transport_state API, the original items are left in ast_sip_transport and kept updated to maintain ABI compatability for third-party modules. They are marked as deprecated and noted that they're now in ast_sip_transport_state. ASTERISK-25606 #close Reported-by: Martin Moučka Change-Id: Ic7a836ea8e786e8def51fe3f8cce855ea54f5f19 --- res/res_pjsip_t38.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'res/res_pjsip_t38.c') diff --git a/res/res_pjsip_t38.c b/res/res_pjsip_t38.c index 2c544bb70..7534d4a49 100644 --- a/res/res_pjsip_t38.c +++ b/res/res_pjsip_t38.c @@ -890,11 +890,12 @@ static int apply_negotiated_sdp_stream(struct ast_sip_session *session, struct a /*! \brief Function which updates the media stream with external media address, if applicable */ static void change_outgoing_sdp_stream_media_address(pjsip_tx_data *tdata, struct pjmedia_sdp_media *stream, struct ast_sip_transport *transport) { + RAII_VAR(struct ast_sip_transport_state *, transport_state, ast_sip_get_transport_state(ast_sorcery_object_get_id(transport)), ao2_cleanup); char host[NI_MAXHOST]; struct ast_sockaddr addr = { { 0, } }; /* If the stream has been rejected there will be no connection line */ - if (!stream->conn) { + if (!stream->conn || !transport_state) { return; } @@ -902,7 +903,7 @@ static void change_outgoing_sdp_stream_media_address(pjsip_tx_data *tdata, struc ast_sockaddr_parse(&addr, host, PARSE_PORT_FORBID); /* Is the address within the SDP inside the same network? */ - if (ast_apply_ha(transport->localnet, &addr) == AST_SENSE_ALLOW) { + if (ast_apply_ha(transport_state->localnet, &addr) == AST_SENSE_ALLOW) { return; } -- cgit v1.2.3