[asterisk-commits] tilghman: branch 1.4 r174885 - in /branches/1.4: apps/app_macro.c main/pbx.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Feb 11 14:54:18 CST 2009


Author: tilghman
Date: Wed Feb 11 14:54:18 2009
New Revision: 174885

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=174885
Log:
Restore a behavior that was recently changed, when we fixed issue #13962 and
issue #13363 (related to issue #6176).  When a hangup occurs during a Macro
execution in earlier 1.4, the h extension would execute within the Macro
context, whereas it was always supposed to execute only within the main context
(where Macro was called).  So this fix checks for an "h" extension in the
deepest macro context where a hangup occurred; if it exists, that "h" extension
executes, otherwise the main context "h" is executed.
(closes issue #14122)
 Reported by: wetwired
 Patches: 
       20090210__bug14122.diff.txt uploaded by Corydon76 (license 14)
 Tested by: andrew

Modified:
    branches/1.4/apps/app_macro.c
    branches/1.4/main/pbx.c

Modified: branches/1.4/apps/app_macro.c
URL: http://svn.digium.com/svn-view/asterisk/branches/1.4/apps/app_macro.c?view=diff&rev=174885&r1=174884&r2=174885
==============================================================================
--- branches/1.4/apps/app_macro.c (original)
+++ branches/1.4/apps/app_macro.c Wed Feb 11 14:54:18 2009
@@ -477,6 +477,23 @@
 		chan->macropriority = 0;
 	}
 
+	/*!\note
+	 * This section is used to restore a behavior that we mistakenly
+	 * changed in issue #6176, then mistakenly reverted in #13962 and
+	 * #13363.  A corresponding change is made in main/pbx.c, where we
+	 * check this variable for existence, then look for the "h" extension
+	 * in that context.
+	 */
+	if (ast_check_hangup(chan) || res < 0) {
+		/* Don't need to lock the channel, as we aren't dereferencing emc.
+		 * The intent here is to grab the deepest context, without overwriting
+		 * in any above context. */
+		const char *emc = pbx_builtin_getvar_helper(chan, "EXIT_MACRO_CONTEXT");
+		if (!emc) {
+			pbx_builtin_setvar_helper(chan, "EXIT_MACRO_CONTEXT", fullmacro);
+		}
+	}
+
 	if (!strcasecmp(chan->context, fullmacro)) {
   		/* If we're leaving the macro normally, restore original information */
 		chan->priority = oldpriority;

Modified: branches/1.4/main/pbx.c
URL: http://svn.digium.com/svn-view/asterisk/branches/1.4/main/pbx.c?view=diff&rev=174885&r1=174884&r2=174885
==============================================================================
--- branches/1.4/main/pbx.c (original)
+++ branches/1.4/main/pbx.c Wed Feb 11 14:54:18 2009
@@ -2365,6 +2365,7 @@
 	int res = 0;
 	int autoloopflag;
 	int error = 0;		/* set an error conditions */
+	const char *emc;
 
 	/* A little initial setup here */
 	if (c->pbx) {
@@ -2542,7 +2543,15 @@
 		ast_log(LOG_WARNING, "Don't know what to do with '%s'\n", c->name);
 	if (res != AST_PBX_KEEPALIVE)
 		ast_softhangup(c, c->hangupcause ? c->hangupcause : AST_CAUSE_NORMAL_CLEARING);
-	if ((res != AST_PBX_KEEPALIVE) && !ast_test_flag(c, AST_FLAG_BRIDGE_HANGUP_RUN) && ast_exists_extension(c, c->context, "h", 1, c->cid.cid_num)) {
+	ast_channel_lock(c);
+	if ((emc = pbx_builtin_getvar_helper(c, "EXIT_MACRO_CONTEXT"))) {
+		emc = ast_strdupa(emc);
+	}
+	ast_channel_unlock(c);
+	if ((res != AST_PBX_KEEPALIVE) && !ast_test_flag(c, AST_FLAG_BRIDGE_HANGUP_RUN) &&
+			((emc && ast_exists_extension(c, emc, "h", 1, c->cid.cid_num)) ||
+			 (ast_exists_extension(c, c->context, "h", 1, c->cid.cid_num) && (emc = c->context)))) {
+		ast_copy_string(c->context, emc, sizeof(c->context));
 		set_ext_pri(c, "h", 1);
 		if (c->cdr && ast_opt_end_cdr_before_h_exten) {
 			ast_cdr_end(c->cdr);




More information about the asterisk-commits mailing list