[svn-commits] kmoore: branch group/ari-greedy-atxfer r419562 - /team/group/ari-greedy-atxfe...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Jul 25 08:06:01 CDT 2014


Author: kmoore
Date: Fri Jul 25 08:05:56 2014
New Revision: 419562

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=419562
Log:
Stasis App: Don't grab swap app name until necessary

Moving the acquisition of the app name into the after-bridge callback
simplifies surrounding code and removes the need for an after-bridge
failure callback.

Modified:
    team/group/ari-greedy-atxfer/res/stasis/stasis_bridge.c

Modified: team/group/ari-greedy-atxfer/res/stasis/stasis_bridge.c
URL: http://svnview.digium.com/svn/asterisk/team/group/ari-greedy-atxfer/res/stasis/stasis_bridge.c?view=diff&rev=419562&r1=419561&r2=419562
==============================================================================
--- team/group/ari-greedy-atxfer/res/stasis/stasis_bridge.c (original)
+++ team/group/ari-greedy-atxfer/res/stasis/stasis_bridge.c Fri Jul 25 08:05:56 2014
@@ -45,9 +45,15 @@
 
 static void bridge_stasis_run_cb(struct ast_channel *chan, void *data)
 {
-	RAII_VAR(char *, app_name, data, ast_free);
+	RAII_VAR(char *, app_name, NULL, ast_free);
 	struct ast_app *app_stasis;
 
+	/* Take ownership of the swap_app memory from the datastore */
+	app_name = app_get_replace_channel_app(chan);
+	if (!app_name) {
+		ast_log(LOG_ERROR, "Failed to get app name for %s (%p)\n", ast_channel_name(chan), chan);
+		return;
+	}
 
 	/* find Stasis() */
 	app_stasis = pbx_findapp("Stasis");
@@ -63,13 +69,6 @@
 
 	/* run Stasis() */
 	pbx_exec(chan, app_stasis, app_name);
-}
-
-static void bridge_stasis_fail_cb(enum ast_bridge_after_cb_reason reason, void *data)
-{
-	char *app_name = data;
-
-	ast_free(app_name);
 }
 
 static int add_channel_to_bridge(
@@ -115,20 +114,10 @@
 
 	if (!control) {
 		/* channel not in Stasis(), get it there */
-		char *swap_app;
-
-		/* Take ownership of the swap_app memory from the datastore */
-		swap_app = app_get_replace_channel_app(bridge_channel->chan);
-		if (!swap_app) {
-			ast_log(LOG_ERROR, "Failed to get app name for channel at %p\n", bridge_channel->chan);
-			return -1;
-		}
-
 		/* Attach after-bridge callback and pass ownership of swap_app to it */
 		if (ast_bridge_set_after_callback(bridge_channel->chan,
-			bridge_stasis_run_cb, bridge_stasis_fail_cb, swap_app)) {
+			bridge_stasis_run_cb, NULL, NULL)) {
 			ast_log(LOG_ERROR, "Failed to set after bridge callback\n");
-			ast_free(swap_app);
 			return -1;
 		}
 




More information about the svn-commits mailing list