summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Bryant <russell@russellbryant.com>2012-02-14 00:43:50 +0000
committerRussell Bryant <russell@russellbryant.com>2012-02-14 00:43:50 +0000
commit33322e38f0a0a0fa6f6d9be8500a6135a6a5715b (patch)
treedf77c0cca9e8c1a5aa33582c515291bcea33ca95
parentb978e785ddaa2179b467051e8b70451ee5e42ec5 (diff)
res_agi: Add AGIEXITONHANGUP variable.
This patch adds a variable AGIEXITONHANGUP for res_agi. If this variable is set to "yes" on a channel, AGI() will exit immediately once a channel hangup has been detected. This was the behavior of AGI() in Asterisk 1.4 and earlier and is still desired by some people. Review: https://reviewboard.asterisk.org/r/1734/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@355102 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r--CHANGES6
-rw-r--r--res/res_agi.c14
2 files changed, 18 insertions, 2 deletions
diff --git a/CHANGES b/CHANGES
index e40ed417f..4b6e3d2fa 100644
--- a/CHANGES
+++ b/CHANGES
@@ -188,6 +188,12 @@ res_corosync
is a replacement for the res_ais module that was in previous releases of
Asterisk.
+AGI
+---
+ * A new channel variable, AGIEXITONHANGUP, has been added which allows
+ Asterisk to behave like it did in Asterisk 1.4 and earlier where the
+ AGI application would exit immediately after a channel hangup is detected.
+
------------------------------------------------------------------------------
--- Functionality changes from Asterisk 1.8 to Asterisk 10 -------------------
------------------------------------------------------------------------------
diff --git a/res/res_agi.c b/res/res_agi.c
index 511f44003..444029161 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -819,7 +819,10 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
hangup from the channel except when using DeadAGI. A fast AGI server will
correspondingly receive a HANGUP inline with the command dialog. Both of theses
signals may be disabled by setting the <variable>AGISIGHUP</variable> channel
- variable to <literal>no</literal> before executing the AGI application.</para>
+ variable to <literal>no</literal> before executing the AGI application.
+ Alternatively, if you would like the AGI application to exit immediately
+ after a channel hangup is detected, set the <variable>AGIEXITONHANGUP</variable>
+ variable to <literal>yes</literal>.</para>
<para>Use the CLI command <literal>agi show commands</literal> to list available agi
commands.</para>
<para>This application sets the following channel variable upon completion:</para>
@@ -3477,10 +3480,14 @@ static enum agi_result run_agi(struct ast_channel *chan, char *request, AGI *agi
int retry = AGI_NANDFS_RETRY;
int send_sighup;
const char *sighup_str;
+ const char *exit_on_hangup_str;
+ int exit_on_hangup;
ast_channel_lock(chan);
sighup_str = pbx_builtin_getvar_helper(chan, "AGISIGHUP");
- send_sighup = ast_strlen_zero(sighup_str) || !ast_false(sighup_str);
+ send_sighup = !ast_false(sighup_str);
+ exit_on_hangup_str = pbx_builtin_getvar_helper(chan, "AGIEXITONHANGUP");
+ exit_on_hangup = ast_true(exit_on_hangup_str);
ast_channel_unlock(chan);
if (!(readf = fdopen(agi->ctrl, "r"))) {
@@ -3504,6 +3511,9 @@ static enum agi_result run_agi(struct ast_channel *chan, char *request, AGI *agi
ast_agi_send(agi->fd, chan, "HANGUP\n");
}
}
+ if (exit_on_hangup) {
+ break;
+ }
}
ms = -1;
if (dead) {