mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-19 08:11:21 +00:00
Merged revisions 229351 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ........ r229351 | tilghman | 2009-11-10 15:22:50 -0600 (Tue, 10 Nov 2009) | 7 lines 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/branches/1.6.0@229352 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -83,6 +83,7 @@ struct gosub_stack_frame {
|
|||||||
unsigned char arguments;
|
unsigned char arguments;
|
||||||
struct varshead varshead;
|
struct varshead varshead;
|
||||||
int priority;
|
int priority;
|
||||||
|
unsigned int is_agi:1;
|
||||||
char *context;
|
char *context;
|
||||||
char extension[0];
|
char extension[0];
|
||||||
};
|
};
|
||||||
@@ -195,6 +196,7 @@ static int return_exec(struct ast_channel *chan, void *data)
|
|||||||
struct gosub_stack_frame *oldframe;
|
struct gosub_stack_frame *oldframe;
|
||||||
AST_LIST_HEAD(, gosub_stack_frame) *oldlist;
|
AST_LIST_HEAD(, gosub_stack_frame) *oldlist;
|
||||||
char *retval = data;
|
char *retval = data;
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
if (!stack_store) {
|
if (!stack_store) {
|
||||||
ast_log(LOG_ERROR, "Return without Gosub: stack is unallocated\n");
|
ast_log(LOG_ERROR, "Return without Gosub: stack is unallocated\n");
|
||||||
@@ -209,6 +211,9 @@ static int return_exec(struct ast_channel *chan, void *data)
|
|||||||
if (!oldframe) {
|
if (!oldframe) {
|
||||||
ast_log(LOG_ERROR, "Return without Gosub: stack is empty\n");
|
ast_log(LOG_ERROR, "Return without Gosub: stack is empty\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
} else if (oldframe->is_agi) {
|
||||||
|
/* Exit from AGI */
|
||||||
|
res = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ast_explicit_goto(chan, oldframe->context, oldframe->extension, oldframe->priority);
|
ast_explicit_goto(chan, oldframe->context, oldframe->extension, oldframe->priority);
|
||||||
@@ -216,7 +221,7 @@ static int return_exec(struct ast_channel *chan, void *data)
|
|||||||
|
|
||||||
/* Set a return value, if any */
|
/* Set a return value, if any */
|
||||||
pbx_builtin_setvar_helper(chan, "GOSUB_RETVAL", S_OR(retval, ""));
|
pbx_builtin_setvar_helper(chan, "GOSUB_RETVAL", S_OR(retval, ""));
|
||||||
return 0;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gosub_exec(struct ast_channel *chan, void *data)
|
static int gosub_exec(struct ast_channel *chan, void *data)
|
||||||
@@ -469,6 +474,11 @@ static int handle_gosub(struct ast_channel *chan, AGI *agi, int argc, char **arg
|
|||||||
if ((res = pbx_exec(chan, theapp, gosub_args)) == 0) {
|
if ((res = pbx_exec(chan, theapp, gosub_args)) == 0) {
|
||||||
struct ast_pbx *pbx = chan->pbx;
|
struct ast_pbx *pbx = chan->pbx;
|
||||||
struct ast_pbx_args args;
|
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));
|
memset(&args, 0, sizeof(args));
|
||||||
args.no_hangup_chan = 1;
|
args.no_hangup_chan = 1;
|
||||||
/* Suppress warning about PBX already existing */
|
/* Suppress warning about PBX already existing */
|
||||||
|
|||||||
Reference in New Issue
Block a user