From: Tilghman Lesher Date: Sun, 5 Feb 2006 17:20:29 +0000 (+0000) Subject: Merged revisions 9156 via svnmerge from X-Git-Tag: 1.4.0-beta1~2717 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b347ddf3c6f5347b899201f89addebd5317ea2fd;p=thirdparty%2Fasterisk.git Merged revisions 9156 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r9156 | tilghman | 2006-02-05 11:10:19 -0600 (Sun, 05 Feb 2006) | 2 lines Bug 6176 - Fix race condition ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@9157 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/apps/app_macro.c b/apps/app_macro.c index a011dc65d3..922fc23eda 100644 --- a/apps/app_macro.c +++ b/apps/app_macro.c @@ -107,7 +107,7 @@ static int macro_exec(struct ast_channel *chan, void *data) char oldcontext[AST_MAX_CONTEXT] = ""; int offset, depth = 0; int setmacrocontext=0; - int autoloopflag; + int autoloopflag, dead = 0; char *save_macro_exten; char *save_macro_context; @@ -208,8 +208,8 @@ static int macro_exec(struct ast_channel *chan, void *data) break; } switch(res) { - case MACRO_EXIT_RESULT: - res = 0; + case MACRO_EXIT_RESULT: + res = 0; goto out; case AST_PBX_KEEPALIVE: if (option_debug) @@ -223,6 +223,7 @@ static int macro_exec(struct ast_channel *chan, void *data) ast_log(LOG_DEBUG, "Spawn extension (%s,%s,%d) exited non-zero on '%s' in macro '%s'\n", chan->context, chan->exten, chan->priority, chan->name, macro); else if (option_verbose > 1) ast_verbose( VERBOSE_PREFIX_2 "Spawn extension (%s, %s, %d) exited non-zero on '%s' in macro '%s'\n", chan->context, chan->exten, chan->priority, chan->name, macro); + dead = 1; goto out; } } @@ -242,37 +243,44 @@ static int macro_exec(struct ast_channel *chan, void *data) out: /* Reset the depth back to what it was when the routine was entered (like if we called Macro recursively) */ snprintf(depthc, sizeof(depthc), "%d", depth); - pbx_builtin_setvar_helper(chan, "MACRO_DEPTH", depthc); + if (!dead) { + pbx_builtin_setvar_helper(chan, "MACRO_DEPTH", depthc); + + ast_set2_flag(chan, autoloopflag, AST_FLAG_IN_AUTOLOOP); + } - ast_set2_flag(chan, autoloopflag, AST_FLAG_IN_AUTOLOOP); - for (x=1; xmacrocontext[0] = '\0'; chan->macroexten[0] = '\0'; chan->macropriority = 0; } - if (!strcasecmp(chan->context, fullmacro)) { + if (!dead && !strcasecmp(chan->context, fullmacro)) { /* If we're leaving the macro normally, restore original information */ chan->priority = oldpriority; ast_copy_string(chan->context, oldcontext, sizeof(chan->context)); @@ -292,7 +300,8 @@ static int macro_exec(struct ast_channel *chan, void *data) } } - pbx_builtin_setvar_helper(chan, "MACRO_OFFSET", save_macro_offset); + if (!dead) + pbx_builtin_setvar_helper(chan, "MACRO_OFFSET", save_macro_offset); if (save_macro_offset) free(save_macro_offset); LOCAL_USER_REMOVE(u);