aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_agi.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-05-01 23:06:23 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-05-01 23:06:23 +0000
commitd1cc29c9c1c324a7421f220482d8cc4f321540ba (patch)
tree3df7d1e791a878179b45272be0b3f3cccf8eeee0 /res/res_agi.c
parent995531248a14d3ac9e88ffc12836176688bb137e (diff)
Modify TIMEOUT() to be accurate down to the millisecond.
(closes issue #10540) Reported by: spendergrass Patches: 20080417__bug10540.diff.txt uploaded by Corydon76 (license 14) Tested by: blitzrage git-svn-id: http://svn.digium.com/svn/asterisk/trunk@115076 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_agi.c')
-rw-r--r--res/res_agi.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/res/res_agi.c b/res/res_agi.c
index 4370654d0..4675b5fb6 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -980,9 +980,9 @@ static int handle_getoption(struct ast_channel *chan, AGI *agi, int argc, char *
if ( argc == 5 )
timeout = atoi(argv[4]);
- else if (chan->pbx->dtimeout) {
+ else if (chan->pbx->dtimeoutms) {
/* by default dtimeout is set to 5sec */
- timeout = chan->pbx->dtimeout * 1000; /* in msec */
+ timeout = chan->pbx->dtimeoutms; /* in msec */
}
if (!(fs = ast_openstream(chan, argv[2], chan->language))) {
@@ -1398,18 +1398,20 @@ static int handle_recordfile(struct ast_channel *chan, AGI *agi, int argc, char
static int handle_autohangup(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
{
- int timeout;
+ double timeout;
+ struct timeval whentohangup = { 0, 0 };
if (argc != 3)
return RESULT_SHOWUSAGE;
- if (sscanf(argv[2], "%d", &timeout) != 1)
+ if (sscanf(argv[2], "%lf", &timeout) != 1)
return RESULT_SHOWUSAGE;
if (timeout < 0)
timeout = 0;
- if (timeout)
- chan->whentohangup = time(NULL) + timeout;
- else
- chan->whentohangup = 0;
+ if (timeout) {
+ whentohangup.tv_sec = timeout;
+ whentohangup.tv_usec = (timeout - whentohangup.tv_sec) * 1000000.0;
+ }
+ ast_channel_setwhentohangup_tv(chan, whentohangup);
ast_agi_fdprintf(chan, agi->fd, "200 result=0\n");
return RESULT_SUCCESS;
}