summaryrefslogtreecommitdiff
path: root/fxotune.c
diff options
context:
space:
mode:
authormogorman <mogorman@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-07-05 21:18:28 +0000
committermogorman <mogorman@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-07-05 21:18:28 +0000
commit70ef1183eba2d2fe4f00668fd3438b7f1c842c94 (patch)
tree12a99983ff1c0773a80faab91ca1f20fbb6f5667 /fxotune.c
parenta2b1c515b2148fc8ac8ba95e5cdfd0dd56d97a53 (diff)
solves an overflow issue with elpased time. from
bug 7264 git-svn-id: http://svn.digium.com/svn/zaptel/trunk@1203 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'fxotune.c')
-rw-r--r--fxotune.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/fxotune.c b/fxotune.c
index 7e0d4eb..770c5d5 100644
--- a/fxotune.c
+++ b/fxotune.c
@@ -100,12 +100,22 @@ static int debug = 0;
static int ensure_silence(struct silence_info *info)
{
struct timeval tv;
- long elapsedms;
+ long int elapsedms;
gettimeofday(&tv, NULL);
- elapsedms = ((tv.tv_sec - info->last_reset.tv_sec) * 1000L + (tv.tv_usec - info->last_reset.tv_usec));
+
+ if (info->last_reset.tv_sec == 0) {
+ /* this is the first request, we will force it to run */
+ elapsedms = -1;
+ } else {
+ /* this is not the first request, we will compute elapsed time */
+ elapsedms = ((tv.tv_sec - info->last_reset.tv_sec) * 1000L + (tv.tv_usec - info->last_reset.tv_usec) / 1000L);
+ }
+ if (debug > 4) {
+ fprintf(stdout, "Reset line request received - elapsed ms = %li / reset after = %ld\n", elapsedms, info->reset_after * 1000L);
+ }
- if (elapsedms < info->reset_after * 1000)
+ if (elapsedms > 0 && elapsedms < info->reset_after * 1000L)
return 0;
if (debug > 1){