[asterisk-commits] rmudgett: branch 12 r425782 - in /branches/12/main: channel.c core_unreal.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Oct 16 21:32:42 CDT 2014


Author: rmudgett
Date: Thu Oct 16 21:32:37 2014
New Revision: 425782

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=425782
Log:
AMI: Add missing VarSet events when a channel inherits variables.

There should be AMI VarSet events when channel variables are inherited by
an outgoing channel.  Also local;2 should generate VarSet events when it
gets all of its channel variables from channel local;1.

ASTERISK-24415 #close
Reported by: Richard Mudgett
Patches:
      jira_asterisk_24415_v12.patch (license #5621) patch uploaded by Richard Mudgett

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

Modified:
    branches/12/main/channel.c
    branches/12/main/core_unreal.c

Modified: branches/12/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/channel.c?view=diff&rev=425782&r1=425781&r2=425782
==============================================================================
--- branches/12/main/channel.c (original)
+++ branches/12/main/channel.c Thu Oct 16 21:32:37 2014
@@ -6299,41 +6299,42 @@
 
 void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_channel *child)
 {
-	struct ast_var_t *current, *newvar;
+	struct ast_var_t *current;
+	struct ast_var_t *newvar;
 	const char *varname;
+	int vartype;
 
 	AST_LIST_TRAVERSE(ast_channel_varshead((struct ast_channel *) parent), current, entries) {
-		int vartype = 0;
-
 		varname = ast_var_full_name(current);
-		if (!varname)
+		if (!varname) {
 			continue;
-
+		}
+
+		vartype = 0;
 		if (varname[0] == '_') {
 			vartype = 1;
-			if (varname[1] == '_')
+			if (varname[1] == '_') {
 				vartype = 2;
+			}
 		}
 
 		switch (vartype) {
 		case 1:
 			newvar = ast_var_assign(&varname[1], ast_var_value(current));
-			if (newvar) {
-				AST_LIST_INSERT_TAIL(ast_channel_varshead(child), newvar, entries);
-				ast_debug(1, "Inheriting variable %s from %s to %s.\n",
-					ast_var_name(newvar), ast_channel_name(parent), ast_channel_name(child));
-			}
 			break;
 		case 2:
 			newvar = ast_var_assign(varname, ast_var_value(current));
-			if (newvar) {
-				AST_LIST_INSERT_TAIL(ast_channel_varshead(child), newvar, entries);
-				ast_debug(1, "Inheriting variable %s from %s to %s.\n",
-					ast_var_name(newvar), ast_channel_name(parent), ast_channel_name(child));
-			}
 			break;
 		default:
-			break;
+			continue;
+		}
+		if (newvar) {
+			ast_debug(1, "Inheriting variable %s from %s to %s.\n",
+				ast_var_full_name(newvar), ast_channel_name(parent),
+				ast_channel_name(child));
+			AST_LIST_INSERT_TAIL(ast_channel_varshead(child), newvar, entries);
+			ast_channel_publish_varset(child, ast_var_full_name(newvar),
+				ast_var_value(newvar));
 		}
 	}
 }

Modified: branches/12/main/core_unreal.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/core_unreal.c?view=diff&rev=425782&r1=425781&r2=425782
==============================================================================
--- branches/12/main/core_unreal.c (original)
+++ branches/12/main/core_unreal.c Thu Oct 16 21:32:37 2014
@@ -36,6 +36,7 @@
 
 #include "asterisk/causes.h"
 #include "asterisk/channel.h"
+#include "asterisk/stasis_channels.h"
 #include "asterisk/pbx.h"
 #include "asterisk/musiconhold.h"
 #include "asterisk/astobj2.h"
@@ -685,6 +686,8 @@
 		clone_var = ast_var_assign(varptr->name, varptr->value);
 		if (clone_var) {
 			AST_LIST_INSERT_TAIL(ast_channel_varshead(semi2), clone_var, entries);
+			ast_channel_publish_varset(semi2, ast_var_full_name(clone_var),
+				ast_var_value(clone_var));
 		}
 	}
 	ast_channel_datastore_inherit(semi1, semi2);




More information about the asterisk-commits mailing list