diff lib/protocols.c @ 222:007145d7d975

2003-7-11 Brian Masney <masneyb@gftp.org> * lib/protocols.c (gftp_calc_kbs) - only call gettimeofday() at the end only if we are throttling this connection * lib/cache.c lib/options.h docs/sample.gftp/gftprc - added cache_ttl option to determine the amount of time that cache entries will stay around * docs/gftp.xml docs/legal.xml docs/figures/* - documentation from Alexander Kirillov <kirillov@math.sunysb.edu> * docs/website - files for generating my main website. They aren't pretty, but hey it works. I'm mainly putting these in CVS just for backup purposes.
author masneyb
date Sun, 13 Jul 2003 12:38:35 +0000
parents 6de9a8280aa4
children a85a097bbb02
line wrap: on
line diff
--- a/lib/protocols.c	Fri Jul 11 20:35:58 2003 +0000
+++ b/lib/protocols.c	Sun Jul 13 12:38:35 2003 +0000
@@ -2303,6 +2303,7 @@
   gftp_file * tempfle;
   struct timeval tv;
   float maxkbs;
+  int waited;
 
   gftp_lookup_request_option (tdata->fromreq, "maxkbs", &maxkbs);
 
@@ -2323,6 +2324,7 @@
   else
     tdata->kbs = tdata->trans_bytes / 1024.0 / start_difftime;
 
+  waited = 0;
   if (maxkbs > 0 && tdata->kbs > maxkbs)
     {
       waitusecs = num_read / 1024.0 / maxkbs * 1000000.0 - start_difftime;
@@ -2332,14 +2334,19 @@
           if (g_thread_supported ())
             g_static_mutex_unlock (&tdata->statmutex);
 
+          waited = 1;
           usleep (waitusecs);
 
           if (g_thread_supported ())
             g_static_mutex_lock (&tdata->statmutex);
         }
+
     }
 
-  gettimeofday (&tdata->lasttime, NULL);
+  if (waited)
+    gettimeofday (&tdata->lasttime, NULL);
+  else
+    memcpy (&tdata->lasttime, &tv, sizeof (tdata->lasttime));
 
   if (g_thread_supported ())
     g_static_mutex_unlock (&tdata->statmutex);