unsigned char arguments;
struct varshead varshead;
int priority;
+ unsigned int is_agi:1;
char *context;
char extension[0];
};
struct gosub_stack_frame *oldframe;
AST_LIST_HEAD(, gosub_stack_frame) *oldlist;
char *retval = data;
+ int res = 0;
if (!stack_store) {
ast_log(LOG_ERROR, "Return without Gosub: stack is unallocated\n");
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);
/* 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, void *data)
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 */