summaryrefslogtreecommitdiff
path: root/apps/app_stack.c
diff options
context:
space:
mode:
authorTilghman Lesher <tilghman@meg.abyt.es>2009-11-10 21:22:50 +0000
committerTilghman Lesher <tilghman@meg.abyt.es>2009-11-10 21:22:50 +0000
commit423d4b8278d744e2c4752bbc183815d42867f10e (patch)
treea380310c47856768ed05d4e79fb9a485f8b5c996 /apps/app_stack.c
parent9c807da785f272791ac0630d335d4585e2cf5634 (diff)
When GOSUB is invoked within an AGI, it may not exit correctly.
(closes issue #16216) Reported by: atis Patches: 20091110__atis_work.diff.txt uploaded by tilghman (license 14) Tested by: atis git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@229351 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_stack.c')
-rw-r--r--apps/app_stack.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/apps/app_stack.c b/apps/app_stack.c
index e32b067d8..5ee22e5a6 100644
--- a/apps/app_stack.c
+++ b/apps/app_stack.c
@@ -199,6 +199,7 @@ struct gosub_stack_frame {
unsigned char arguments;
struct varshead varshead;
int priority;
+ unsigned int is_agi:1;
char *context;
char extension[0];
};
@@ -311,6 +312,7 @@ static int return_exec(struct ast_channel *chan, const char *data)
struct gosub_stack_frame *oldframe;
AST_LIST_HEAD(, gosub_stack_frame) *oldlist;
const char *retval = data;
+ int res = 0;
if (!stack_store) {
ast_log(LOG_ERROR, "Return without Gosub: stack is unallocated\n");
@@ -325,6 +327,9 @@ static int return_exec(struct ast_channel *chan, const char *data)
if (!oldframe) {
ast_log(LOG_ERROR, "Return without Gosub: stack is empty\n");
return -1;
+ } else if (oldframe->is_agi) {
+ /* Exit from AGI */
+ res = -1;
}
ast_explicit_goto(chan, oldframe->context, oldframe->extension, oldframe->priority);
@@ -332,7 +337,7 @@ static int return_exec(struct ast_channel *chan, const char *data)
/* Set a return value, if any */
pbx_builtin_setvar_helper(chan, "GOSUB_RETVAL", S_OR(retval, ""));
- return 0;
+ return res;
}
static int gosub_exec(struct ast_channel *chan, const char *data)
@@ -619,6 +624,11 @@ static int handle_gosub(struct ast_channel *chan, AGI *agi, int argc, const char
if ((res = pbx_exec(chan, theapp, gosub_args)) == 0) {
struct ast_pbx *pbx = chan->pbx;
struct ast_pbx_args args;
+ struct ast_datastore *stack_store = ast_channel_datastore_find(chan, &stack_info, NULL);
+ AST_LIST_HEAD(, gosub_stack_frame) *oldlist = stack_store->data;
+ struct gosub_stack_frame *cur = AST_LIST_FIRST(oldlist);
+ cur->is_agi = 1;
+
memset(&args, 0, sizeof(args));
args.no_hangup_chan = 1;
/* Suppress warning about PBX already existing */