aboutsummaryrefslogtreecommitdiffstats
path: root/apps
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 /apps
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 'apps')
-rw-r--r--apps/app_dial.c7
-rw-r--r--apps/app_disa.c4
-rw-r--r--apps/app_dumpchan.c2
-rw-r--r--apps/app_queue.c2
-rw-r--r--apps/app_read.c2
-rw-r--r--apps/app_readexten.c4
-rw-r--r--apps/app_rpt.c16
-rw-r--r--apps/app_speech_utils.c14
8 files changed, 27 insertions, 24 deletions
diff --git a/apps/app_dial.c b/apps/app_dial.c
index 5730d99d7..d72a85411 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -1472,7 +1472,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
tc->appl = "AppDial";
tc->data = "(Outgoing Line)";
- tc->whentohangup = 0;
+ memset(&tc->whentohangup, 0, sizeof(tc->whentohangup));
S_REPLACE(tc->cid.cid_num, ast_strdup(chan->cid.cid_num));
S_REPLACE(tc->cid.cid_name, ast_strdup(chan->cid.cid_name));
@@ -1839,7 +1839,8 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
if (!res) {
if (calldurationlimit > 0) {
- peer->whentohangup = time(NULL) + calldurationlimit;
+ struct timeval whentohangup = { calldurationlimit, 0 };
+ peer->whentohangup = ast_tvadd(ast_tvnow(), whentohangup);
}
if (!ast_strlen_zero(dtmfcalled)) {
ast_verb(3, "Sending DTMF '%s' to the called party.\n", dtmfcalled);
@@ -1967,7 +1968,7 @@ out:
if ((ast_test_flag64(peerflags, OPT_GO_ON)) && !ast_check_hangup(chan) && (res != AST_PBX_KEEPALIVE) && (res != AST_PBX_INCOMPLETE)) {
if (calldurationlimit)
- chan->whentohangup = 0;
+ memset(&chan->whentohangup, 0, sizeof(chan->whentohangup));
res = 0;
}
diff --git a/apps/app_disa.c b/apps/app_disa.c
index 16c2675d3..53bcc2c99 100644
--- a/apps/app_disa.c
+++ b/apps/app_disa.c
@@ -116,8 +116,8 @@ static void play_dialtone(struct ast_channel *chan, char *mailbox)
static int disa_exec(struct ast_channel *chan, void *data)
{
int i = 0, j, k = 0, did_ignore = 0, special_noanswer = 0;
- int firstdigittimeout = (chan->pbx ? chan->pbx->rtimeout * 1000 : 20000);
- int digittimeout = (chan->pbx ? chan->pbx->dtimeout * 1000 : 10000);
+ int firstdigittimeout = (chan->pbx ? chan->pbx->rtimeoutms : 20000);
+ int digittimeout = (chan->pbx ? chan->pbx->dtimeoutms : 10000);
struct ast_flags flags;
char *tmp, exten[AST_MAX_EXTENSION] = "", acctcode[20]="";
char pwline[256];
diff --git a/apps/app_dumpchan.c b/apps/app_dumpchan.c
index d01ea7aed..7742633fd 100644
--- a/apps/app_dumpchan.c
+++ b/apps/app_dumpchan.c
@@ -115,7 +115,7 @@ static int serialize_showchan(struct ast_channel *c, char *buf, size_t size)
ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->rawwriteformat),
ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->rawreadformat),
c->fds[0], c->fin & ~DEBUGCHAN_FLAG, (c->fin & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
- c->fout & ~DEBUGCHAN_FLAG, (c->fout & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "", (long)c->whentohangup,
+ c->fout & ~DEBUGCHAN_FLAG, (c->fout & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "", (long)c->whentohangup.tv_sec,
hour,
min,
sec,
diff --git a/apps/app_queue.c b/apps/app_queue.c
index ad87ad586..63f84b24d 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -2228,7 +2228,7 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies
tmp->chan->appl = "AppQueue";
tmp->chan->data = "(Outgoing Line)";
- tmp->chan->whentohangup = 0;
+ memset(&tmp->chan->whentohangup, 0, sizeof(tmp->chan->whentohangup));
if (tmp->chan->cid.cid_num)
ast_free(tmp->chan->cid.cid_num);
tmp->chan->cid.cid_num = ast_strdup(qe->chan->cid.cid_num);
diff --git a/apps/app_read.c b/apps/app_read.c
index a7fdf624b..917421010 100644
--- a/apps/app_read.c
+++ b/apps/app_read.c
@@ -162,7 +162,7 @@ static int read_exec(struct ast_channel *chan, void *data)
ast_stopstream(chan);
if (ts && ts->data[0]) {
if (!to)
- to = chan->pbx ? chan->pbx->rtimeout * 1000 : 6000;
+ to = chan->pbx ? chan->pbx->rtimeoutms : 6000;
res = ast_playtones_start(chan, 0, ts->data, 0);
for (x = 0; x < maxdigits; ) {
res = ast_waitfordigit(chan, to);
diff --git a/apps/app_readexten.c b/apps/app_readexten.c
index cb4fd8c2a..93ca4e670 100644
--- a/apps/app_readexten.c
+++ b/apps/app_readexten.c
@@ -121,10 +121,10 @@ static int readexten_exec(struct ast_channel *chan, void *data)
}
if (timeout <= 0)
- timeout = chan->pbx ? chan->pbx->rtimeout * 1000 : 10000;
+ timeout = chan->pbx ? chan->pbx->rtimeoutms : 10000;
if (digit_timeout <= 0)
- digit_timeout = chan->pbx ? chan->pbx->dtimeout * 1000 : 5000;
+ digit_timeout = chan->pbx ? chan->pbx->dtimeoutms : 5000;
if (ast_test_flag(&flags, OPT_INDICATION) && !ast_strlen_zero(arglist.filename))
ts = ast_get_indication_tone(chan->zone, arglist.filename);
diff --git a/apps/app_rpt.c b/apps/app_rpt.c
index d91b45f52..cf64d12d4 100644
--- a/apps/app_rpt.c
+++ b/apps/app_rpt.c
@@ -298,6 +298,8 @@ static char *remote_rig_rbi = "rbi";
static pthread_t rpt_master_thread;
+struct timeval cancel_atimeout = { 0, 0 };
+
struct rpt;
struct rpt_link
@@ -2930,7 +2932,7 @@ static int function_ilink(struct rpt *myrpt, char *param, char *digits, int comm
if (l->chan) {
ast_set_read_format(l->chan, AST_FORMAT_SLINEAR);
ast_set_write_format(l->chan, AST_FORMAT_SLINEAR);
- l->chan->whentohangup = 0;
+ ast_channel_setwhentohangup_tv(l->chan, cancel_atimeout);
l->chan->appl = "Apprpt";
l->chan->data = "(Remote Rx)";
ast_verb(3, "rpt (remote) initiating call to %s/%s on %s\n",
@@ -3041,7 +3043,7 @@ static int function_ilink(struct rpt *myrpt, char *param, char *digits, int comm
if (l->chan) {
ast_set_read_format(l->chan, AST_FORMAT_SLINEAR);
ast_set_write_format(l->chan, AST_FORMAT_SLINEAR);
- l->chan->whentohangup = 0;
+ ast_channel_setwhentohangup_tv(l->chan, cancel_atimeout);
l->chan->appl = "Apprpt";
l->chan->data = "(Remote Rx)";
ast_verb(3, "rpt (remote) initiating call to %s/%s on %s\n",
@@ -5462,7 +5464,7 @@ static int attempt_reconnect(struct rpt *myrpt, struct rpt_link *l)
if (l->chan) {
ast_set_read_format(l->chan, AST_FORMAT_SLINEAR);
ast_set_write_format(l->chan, AST_FORMAT_SLINEAR);
- l->chan->whentohangup = 0;
+ ast_channel_setwhentohangup_tv(l->chan, cancel_atimeout);
l->chan->appl = "Apprpt";
l->chan->data = "(Remote Rx)";
ast_verb(3, "rpt (attempt_reconnect) initiating call to %s/%s on %s\n",
@@ -5699,7 +5701,7 @@ static void *rpt(void *this)
}
ast_set_read_format(myrpt->rxchannel, AST_FORMAT_SLINEAR);
ast_set_write_format(myrpt->rxchannel, AST_FORMAT_SLINEAR);
- myrpt->rxchannel->whentohangup = 0;
+ ast_channel_setwhentohangup_tv(myrpt->rxchannel, cancel_atimeout);
myrpt->rxchannel->appl = "Apprpt";
myrpt->rxchannel->data = "(Repeater Rx)";
ast_verb(3, "rpt (Rx) initiating call to %s/%s on %s\n",
@@ -5740,7 +5742,7 @@ static void *rpt(void *this)
}
ast_set_read_format(myrpt->txchannel, AST_FORMAT_SLINEAR);
ast_set_write_format(myrpt->txchannel, AST_FORMAT_SLINEAR);
- myrpt->txchannel->whentohangup = 0;
+ ast_channel_setwhentohangup_tv(myrpt->txchannel, cancel_atimeout);
myrpt->txchannel->appl = "Apprpt";
myrpt->txchannel->data = "(Repeater Tx)";
ast_verb(3, "rpt (Tx) initiating call to %s/%s on %s\n",
@@ -7109,7 +7111,7 @@ static int rpt_exec(struct ast_channel *chan, void *data)
if (myrpt->rxchannel) {
ast_set_read_format(myrpt->rxchannel, AST_FORMAT_SLINEAR);
ast_set_write_format(myrpt->rxchannel, AST_FORMAT_SLINEAR);
- myrpt->rxchannel->whentohangup = 0;
+ ast_channel_setwhentohangup_tv(myrpt->rxchannel, cancel_atimeout);
myrpt->rxchannel->appl = "Apprpt";
myrpt->rxchannel->data = "(Link Rx)";
ast_verb(3, "rpt (Rx) initiating call to %s/%s on %s\n",
@@ -7136,7 +7138,7 @@ static int rpt_exec(struct ast_channel *chan, void *data)
if (myrpt->txchannel) {
ast_set_read_format(myrpt->txchannel, AST_FORMAT_SLINEAR);
ast_set_write_format(myrpt->txchannel, AST_FORMAT_SLINEAR);
- myrpt->txchannel->whentohangup = 0;
+ ast_channel_setwhentohangup_tv(myrpt->txchannel, cancel_atimeout);
myrpt->txchannel->appl = "Apprpt";
myrpt->txchannel->data = "(Link Tx)";
ast_verb(3, "rpt (Tx) initiating call to %s/%s on %s\n",
diff --git a/apps/app_speech_utils.c b/apps/app_speech_utils.c
index 4677c33b6..5082478af 100644
--- a/apps/app_speech_utils.c
+++ b/apps/app_speech_utils.c
@@ -513,7 +513,7 @@ static int speech_background(struct ast_channel *chan, void *data)
struct ast_frame *f = NULL;
int oldreadformat = AST_FORMAT_SLINEAR;
char dtmf[AST_MAX_EXTENSION] = "";
- time_t start, current;
+ struct timeval start = { 0, 0 }, current;
struct ast_datastore *datastore = NULL;
char *parse, *filename_tmp = NULL, *filename = NULL, tmp[2] = "", dtmf_terminator = '#';
const char *tmp2 = NULL;
@@ -552,7 +552,7 @@ static int speech_background(struct ast_channel *chan, void *data)
/* Yay sound file */
filename_tmp = ast_strdupa(args.soundfile);
if (!ast_strlen_zero(args.timeout)) {
- if ((timeout = atoi(args.timeout)) == 0)
+ if ((timeout = atof(args.timeout) * 1000.0) == 0)
timeout = -1;
} else
timeout = 0;
@@ -612,8 +612,8 @@ static int speech_background(struct ast_channel *chan, void *data)
/* Do timeout check (shared between audio/dtmf) */
if ((!quieted || strlen(dtmf)) && started == 1) {
- time(&current);
- if ((current-start) >= timeout) {
+ current = ast_tvnow();
+ if ((ast_tvdiff_ms(start, current)) >= timeout) {
done = 1;
if (f)
ast_frfree(f);
@@ -642,7 +642,7 @@ static int speech_background(struct ast_channel *chan, void *data)
ast_frfree(f);
break;
}
- time(&start);
+ start = ast_tvnow();
started = 1;
}
/* Write audio frame out to speech engine if no DTMF has been received */
@@ -701,10 +701,10 @@ static int speech_background(struct ast_channel *chan, void *data)
}
if (!started) {
/* Change timeout to be 5 seconds for DTMF input */
- timeout = (chan->pbx && chan->pbx->dtimeout) ? chan->pbx->dtimeout : 5;
+ timeout = (chan->pbx && chan->pbx->dtimeoutms) ? chan->pbx->dtimeoutms : 5000;
started = 1;
}
- time(&start);
+ start = ast_tvnow();
snprintf(tmp, sizeof(tmp), "%c", f->subclass);
strncat(dtmf, tmp, sizeof(dtmf) - strlen(dtmf) - 1);
/* If the maximum length of the DTMF has been reached, stop now */