aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_macro.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-02-07 15:33:51 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-02-07 15:33:51 +0000
commit082fc16b8e66094e0663846c53bc385468ee945e (patch)
tree0929553e96c0d5aaec1018b713af77a904c1cd28 /apps/app_macro.c
parent3fab98fbb13e43c32666a28bcfa9f693c16b56e0 (diff)
Merged revisions 53354 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r53354 | tilghman | 2007-02-07 09:30:02 -0600 (Wed, 07 Feb 2007) | 2 lines Issue 7440 - Macro called from Macro from the h extension exits prematurely ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@53355 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_macro.c')
-rw-r--r--apps/app_macro.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/apps/app_macro.c b/apps/app_macro.c
index 5eeecff11..64becf029 100644
--- a/apps/app_macro.c
+++ b/apps/app_macro.c
@@ -115,9 +115,10 @@ static int _macro_exec(struct ast_channel *chan, void *data, int exclusive)
int oldpriority;
char pc[80], depthc[12];
char oldcontext[AST_MAX_CONTEXT] = "";
+ const char *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;
@@ -141,6 +142,13 @@ static int _macro_exec(struct ast_channel *chan, void *data, int exclusive)
s = pbx_builtin_getvar_helper(chan, "MACRO_DEPTH");
if (s)
sscanf(s, "%d", &depth);
+ /* 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");
ast_module_user_remove(u);
@@ -263,7 +271,7 @@ static int _macro_exec(struct ast_channel *chan, void *data, int exclusive)
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;