aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-02-07 15:30:02 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-02-07 15:30:02 +0000
commit0ef352eb0db10e4a61802e80091d2275b3ac4027 (patch)
treee6e25904ccc17dc39b8c394300473f091d128e53 /apps
parentd494cfb5ea3f2b4991493d5c966e1667c9e059a0 (diff)
Issue 7440 - Macro called from Macro from the h extension exits prematurely
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2@53354 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r--apps/app_macro.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/apps/app_macro.c b/apps/app_macro.c
index 44d3d0610..425836278 100644
--- a/apps/app_macro.c
+++ b/apps/app_macro.c
@@ -107,10 +107,10 @@ static int macro_exec(struct ast_channel *chan, void *data)
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;
@@ -138,6 +138,13 @@ static int macro_exec(struct ast_channel *chan, void *data)
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");
LOCAL_USER_REMOVE(u);
@@ -252,7 +259,7 @@ static int macro_exec(struct ast_channel *chan, void *data)
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;