[asterisk-commits] tilghman: branch 1.2 r53354 - /branches/1.2/apps/app_macro.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Feb 7 08:30:04 MST 2007


Author: tilghman
Date: Wed Feb  7 09:30:02 2007
New Revision: 53354

URL: http://svn.digium.com/view/asterisk?view=rev&rev=53354
Log:
Issue 7440 - Macro called from Macro from the h extension exits prematurely

Modified:
    branches/1.2/apps/app_macro.c

Modified: branches/1.2/apps/app_macro.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/apps/app_macro.c?view=diff&rev=53354&r1=53353&r2=53354
==============================================================================
--- branches/1.2/apps/app_macro.c (original)
+++ branches/1.2/apps/app_macro.c Wed Feb  7 09:30:02 2007
@@ -107,10 +107,10 @@
 	int oldpriority;
 	char pc[80], depthc[12];
 	char oldcontext[AST_MAX_CONTEXT] = "";
-	char *offsets, *s;
+	char *offsets, *s, *inhangupc;
 	int offset, depth = 0, maxdepth = 7;
 	int setmacrocontext=0;
-	int autoloopflag, dead = 0;
+	int autoloopflag, dead = 0, inhangup = 0;
   
 	char *save_macro_exten;
 	char *save_macro_context;
@@ -137,6 +137,13 @@
 	} else {
 		depth = 0;
 	}
+
+	/* Used for detecting whether to return when a Macro is called from another Macro after hangup */
+	if (strcmp(chan->exten, "h") == 0)
+		pbx_builtin_setvar_helper(chan, "MACRO_IN_HANGUP", "1");
+	inhangupc = pbx_builtin_getvar_helper(chan, "MACRO_IN_HANGUP");
+	if (!ast_strlen_zero(inhangupc))
+		sscanf(inhangupc, "%d", &inhangup);
 
 	if (depth >= maxdepth) {
 		ast_log(LOG_ERROR, "Macro():  possible infinite loop detected.  Returning early.\n");
@@ -252,7 +259,7 @@
 			break;
 		}
 		/* don't stop executing extensions when we're in "h" */
-		if (chan->_softhangup && strcasecmp(oldexten,"h") && strcasecmp(chan->macroexten,"h")) {
+		if (chan->_softhangup && !inhangup) {
 			ast_log(LOG_DEBUG, "Extension %s, macroexten %s, priority %d returned normally even though call was hung up\n",
 				chan->exten, chan->macroexten, chan->priority);
 			goto out;



More information about the asterisk-commits mailing list