mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
res_agi: Prevent an AGI from eating frames it should not. (Re-do)
A dialplan intercept routine is equivalent to an interrupt routine. As such, the routine must be done quickly and you do not have access to the media stream. These restrictions are necessary because the media stream is the responsibility of some other code and interfering with or delaying that processing is bad. A possible future dialplan processing architecture change may allow the interception routine to run in a different thread from the main thread handling the media and remove the execution time restriction. * Made res_agi.c:run_agi() running an AGI in an interception routine run in DeadAGI mode. No touchy channel frames. ASTERISK-25951 ASTERISK-26343 ASTERISK-26716 Change-Id: I638f147ca7a7f2590d7194a8ef4090eb191e4e43
This commit is contained in:
@@ -4073,7 +4073,7 @@ static enum agi_result agi_handle_command(struct ast_channel *chan, AGI *agi, ch
|
||||
break;
|
||||
}
|
||||
} else if (c) {
|
||||
ami_res = "Command Not Permitted on a dead channel";
|
||||
ami_res = "Command Not Permitted on a dead channel or intercept routine";
|
||||
resultcode = 511;
|
||||
|
||||
ast_agi_send(agi->fd, chan, "%d %s\n", resultcode, ami_res);
|
||||
@@ -4109,6 +4109,8 @@ static enum agi_result run_agi(struct ast_channel *chan, char *request, AGI *agi
|
||||
const char *sighup_str;
|
||||
const char *exit_on_hangup_str;
|
||||
int exit_on_hangup;
|
||||
/*! Running in an interception routine is like DeadAGI mode. No touchy the channel frames. */
|
||||
int in_intercept = ast_channel_get_intercept_mode();
|
||||
|
||||
ast_channel_lock(chan);
|
||||
sighup_str = pbx_builtin_getvar_helper(chan, "AGISIGHUP");
|
||||
@@ -4143,7 +4145,7 @@ static enum agi_result run_agi(struct ast_channel *chan, char *request, AGI *agi
|
||||
}
|
||||
}
|
||||
ms = -1;
|
||||
if (dead) {
|
||||
if (dead || in_intercept) {
|
||||
c = ast_waitfor_nandfds(&chan, 0, &agi->ctrl, 1, NULL, &outfd, &ms);
|
||||
} else if (!ast_check_hangup(chan)) {
|
||||
c = ast_waitfor_nandfds(&chan, 1, &agi->ctrl, 1, NULL, &outfd, &ms);
|
||||
@@ -4221,10 +4223,10 @@ static enum agi_result run_agi(struct ast_channel *chan, char *request, AGI *agi
|
||||
|
||||
if (agidebug)
|
||||
ast_verbose("<%s>AGI Rx << %s\n", ast_channel_name(chan), buf);
|
||||
cmd_status = agi_handle_command(chan, agi, buf, dead);
|
||||
cmd_status = agi_handle_command(chan, agi, buf, dead || in_intercept);
|
||||
switch (cmd_status) {
|
||||
case AGI_RESULT_FAILURE:
|
||||
if (dead || !ast_check_hangup(chan)) {
|
||||
if (dead || in_intercept || !ast_check_hangup(chan)) {
|
||||
/* The failure was not because of a hangup. */
|
||||
returnstatus = AGI_RESULT_FAILURE;
|
||||
}
|
||||
|
Reference in New Issue
Block a user