[asterisk-commits] app dial: Hold reference to calling channel formats when dia... (asterisk[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jun 24 17:07:08 CDT 2015


Matt Jordan has submitted this change and it was merged.

Change subject: app_dial: Hold reference to calling channel formats when dialing outbound.
......................................................................


app_dial: Hold reference to calling channel formats when dialing outbound.

Currently when requesting a channel the native formats of the
calling channel are provided to the core for usage when dialing
the outbound channel. This occurs without holding the channel lock
or keeping a reference to the formats. This is problematic as
the channel driver may end up changing the formats during this time.
In the case of chan_sip this happens when an SDP negotiation
completes.

This change makes it so app_dial keeps a reference to the native
formats of the calling channel which guarantees that they will
remain valid for the period of time needed.

ASTERISK-25172 #close

Change-Id: I2f0a67bd0d5d14c3bdbaae552b4b1613a283f0db
---
M apps/app_dial.c
1 file changed, 18 insertions(+), 2 deletions(-)

Approvals:
  Richard Mudgett: Looks good to me, but someone else must approve
  Matt Jordan: Looks good to me, approved; Verified



diff --git a/apps/app_dial.c b/apps/app_dial.c
index 895d4b8..46014c6 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -872,8 +872,17 @@
 		c = o->chan = NULL;
 		cause = AST_CAUSE_BUSY;
 	} else {
+		struct ast_format_cap *nativeformats;
+
+		ast_channel_lock(in);
+		nativeformats = ao2_bump(ast_channel_nativeformats(in));
+		ast_channel_unlock(in);
+
 		/* Setup parameters */
-		c = o->chan = ast_request(tech, ast_channel_nativeformats(in), NULL, in, stuff, &cause);
+		c = o->chan = ast_request(tech, nativeformats, NULL, in, stuff, &cause);
+
+		ao2_cleanup(nativeformats);
+
 		if (c) {
 			if (single && !caller_entertained) {
 				ast_channel_make_compatible(in, o->chan);
@@ -2323,6 +2332,7 @@
 		char *tech = strsep(&number, "/");
 		size_t tech_len;
 		size_t number_len;
+		struct ast_format_cap *nativeformats;
 
 		num_dialed++;
 		if (ast_strlen_zero(number)) {
@@ -2373,9 +2383,15 @@
 		 * through the CONNECTED_LINE dialplan function.
 		 */
 		ast_party_connected_line_copy(&tmp->connected, ast_channel_connected(chan));
+
+		nativeformats = ao2_bump(ast_channel_nativeformats(chan));
+
 		ast_channel_unlock(chan);
 
-		tc = ast_request(tmp->tech, ast_channel_nativeformats(chan), NULL, chan, tmp->number, &cause);
+		tc = ast_request(tmp->tech, nativeformats, NULL, chan, tmp->number, &cause);
+
+		ao2_cleanup(nativeformats);
+
 		if (!tc) {
 			/* If we can't, just go on to the next call */
 			ast_log(LOG_WARNING, "Unable to create channel of type '%s' (cause %d - %s)\n",

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I2f0a67bd0d5d14c3bdbaae552b4b1613a283f0db
Gerrit-PatchSet: 2
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>



More information about the asterisk-commits mailing list