]> sjero.net Git - wget/commitdiff
[svn] Reset the sleep_adjust limit value for new downloads. Fixes Debian bug
authorhniksic <devnull@localhost>
Thu, 5 May 2005 09:48:08 +0000 (02:48 -0700)
committerhniksic <devnull@localhost>
Thu, 5 May 2005 09:48:08 +0000 (02:48 -0700)
232276.

src/ChangeLog
src/retr.c

index 83ac595b8e4764892f5575613dec049066d21d7a..58143fa89092aacc01ce4c92fdd3fc502d7297fa 100644 (file)
@@ -1,3 +1,9 @@
+2005-05-05  Hrvoje Niksic  <hniksic@xemacs.org>
+
+       * retr.c (limit_bandwidth_reset): Reset sleep_adjust.
+       (limit_bandwidth): Don't allow huge "adjustment" values that
+       result from being suspended for a while.
+
 2005-05-04  Hrvoje Niksic  <hniksic@xemacs.org>
 
        * wget.h: If gettext was found but libtintl.h wasn't, declare
index c5c1532ba7188c7c39ef0dd6315e3fdf984a76e9..493b830f9f8c8e2dab30259dd6f8dd7757b7aa29 100644 (file)
@@ -82,6 +82,7 @@ limit_bandwidth_reset (void)
 {
   limit_data.chunk_bytes = 0;
   limit_data.chunk_start = 0;
+  limit_data.sleep_adjust = 0;
 }
 
 /* Limit the bandwidth by pausing the download for an amount of time.
@@ -125,6 +126,12 @@ limit_bandwidth (wgint bytes, struct ptimer *timer)
         desired and the actual sleep, and adjust the next sleep by
         that amount.  */
       limit_data.sleep_adjust = slp - (t1 - t0);
+      /* If sleep_adjust is very large, it's likely due to suspension
+        and not clock inaccuracy.  Don't enforce those.  */
+      if (limit_data.sleep_adjust > 500)
+       limit_data.sleep_adjust = 500;
+      else if (limit_data.sleep_adjust < -500)
+       limit_data.sleep_adjust = -500;
     }
 
   limit_data.chunk_bytes = 0;