[asterisk-commits] file: trunk r402337 - in /trunk: ./ res/stasis/control.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Nov 1 07:13:10 CDT 2013


Author: file
Date: Fri Nov  1 07:13:09 2013
New Revision: 402337

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=402337
Log:
res_stasis: Ensure the channel is always departed from the bridge when it leaves.

This change adds a command to the command queue to explicitly depart the channel
from the bridge when it is told it has left. If the channel has already been departed
or has entered a different bridge this command will become a no-op.

(closes issue ASTERISK-22703)
Reported by: John Bigelow

(closes issue ASTERISK-22634)
Reported by: Kevin Harwell

Review: https://reviewboard.asterisk.org/r/2965/
........

Merged revisions 402336 from http://svn.asterisk.org/svn/asterisk/branches/12

Modified:
    trunk/   (props changed)
    trunk/res/stasis/control.c

Propchange: trunk/
------------------------------------------------------------------------------
--- branch-12-merged (original)
+++ branch-12-merged Fri Nov  1 07:13:09 2013
@@ -1,1 +1,1 @@
-/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-402276,402285,402289,402327
+/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-402276,402285,402289,402327,402336

Modified: trunk/res/stasis/control.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/stasis/control.c?view=diff&rev=402337&r1=402336&r2=402337
==============================================================================
--- trunk/res/stasis/control.c (original)
+++ trunk/res/stasis/control.c Fri Nov  1 07:13:09 2013
@@ -489,11 +489,34 @@
 	}
 }
 
+static void *bridge_channel_depart(struct stasis_app_control *control,
+	struct ast_channel *chan, void *data)
+{
+	RAII_VAR(struct ast_bridge_channel *, bridge_channel, data, ao2_cleanup);
+
+	{
+		SCOPED_CHANNELLOCK(lock, chan);
+
+		if (bridge_channel != ast_channel_internal_bridge_channel(chan)) {
+			ast_debug(3, "%s: Channel is no longer in departable state\n",
+				ast_channel_uniqueid(chan));
+			return NULL;
+		}
+	}
+
+	ast_debug(3, "%s: Channel departing bridge\n",
+		ast_channel_uniqueid(chan));
+
+	ast_bridge_depart(chan);
+
+	return NULL;
+}
 
 static void bridge_after_cb(struct ast_channel *chan, void *data)
 {
 	struct stasis_app_control *control = data;
 	SCOPED_AO2LOCK(lock, control);
+	struct ast_bridge_channel *bridge_channel;
 
 	ast_debug(3, "%s, %s: Channel leaving bridge\n",
 		ast_channel_uniqueid(chan), control->bridge->uniqueid);
@@ -507,8 +530,15 @@
 	/* No longer in the bridge */
 	control->bridge = NULL;
 
-	/* Wakeup the command_queue loop */
-	exec_command(control, NULL, NULL);
+	/* Get the bridge channel so we don't depart from the wrong bridge */
+	ast_channel_lock(chan);
+	bridge_channel = ast_channel_get_bridge_channel(chan);
+	ast_channel_unlock(chan);
+
+	/* Depart this channel from the bridge using the command queue if possible */
+	if (stasis_app_send_command_async(control, bridge_channel_depart, bridge_channel)) {
+		ao2_cleanup(bridge_channel);
+	}
 }
 
 static void bridge_after_cb_failed(enum ast_bridge_after_cb_reason reason,




More information about the asterisk-commits mailing list