[zaptel-commits] trunk r1203 - /trunk/fxotune.c
zaptel-commits at lists.digium.com
zaptel-commits at lists.digium.com
Wed Jul 5 14:18:29 MST 2006
Author: mogorman
Date: Wed Jul 5 16:18:28 2006
New Revision: 1203
URL: http://svn.digium.com/view/zaptel?rev=1203&view=rev
Log:
solves an overflow issue with elpased time. from
bug 7264
Modified:
trunk/fxotune.c
Modified: trunk/fxotune.c
URL: http://svn.digium.com/view/zaptel/trunk/fxotune.c?rev=1203&r1=1202&r2=1203&view=diff
==============================================================================
--- trunk/fxotune.c (original)
+++ trunk/fxotune.c Wed Jul 5 16:18:28 2006
@@ -100,12 +100,22 @@
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 (elapsedms < info->reset_after * 1000)
+
+ 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 > 0 && elapsedms < info->reset_after * 1000L)
return 0;
if (debug > 1){
More information about the zaptel-commits
mailing list