logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

patch calc_rate crash: msg#00023

Subject: patch calc_rate crash
wouldn't this fix the crash when the system clock is changed mid-download
or the download is fast?

Index: src/retr.c
===================================================================
RCS file: /pack/anoncvs/wget/src/retr.c,v
retrieving revision 1.55
diff -u -u -r1.55 retr.c
--- src/retr.c  2002/05/18 02:16:24     1.55
+++ src/retr.c  2003/05/14 20:09:18
@@ -260,14 +260,21 @@
 {
   double dlrate;

-  assert (msecs >= 0);
+  /* assert (msecs >= 0); */
+  /* the above crashes wget when download is fast */
+  /* or the system clock is changed mid-stream */
   assert (bytes >= 0);

-  if (msecs == 0)
+  if (msecs == 0) {
     /* If elapsed time is 0, it means we're under the granularity of
        the timer.  This often happens on systems that use time() for
        the timer.  */
     msecs = wtimer_granularity ();
+  } else if (msecs < 0) {
+    logprintf (LOG_NOTQUIET, "\Download time recorded was negative, \
+unable to calculate rate of download\n");
+    msecs = wtimer_granularity ();
+  }

   dlrate = (double)1000 * bytes / msecs;
   if (dlrate < 1024.0)

Attachment: wget_rate-crash-bug.diff-u
Description: Text document

<Prev in Thread] Current Thread [Next in Thread>