wierd duration shown in progress with 0 byte files

Paul Slootman paul at debian.org
Fri Mar 4 22:13:22 GMT 2005


While trying out the 2.6.4-pre2, I noticed something wierd with
--progress; it shows:

ads/promotions.MYD
           0 100%    0.00kB/s  519:35:46  (61, 56.3% of 597)

This is quite reproducable whenever an empty file is transferred (or
created on the receiving end).

Commandline used was:

rsync -zave 'ssh -c arcfour' --progress --stats --delete lisa:/var/lib/mysql/ .

BTW, this also happened with 2.6.0 which was first installed on these
systems.

I looked into progress.c, but beyond eliminating some redundant code :-)
I couldn't fix it quickly. It looks like something isn't being
initialised: the duration shown is always the same during one run; when
removing these empty files and doing a new run, they all show the same
large value, which will be different from the previous run.

This is my little improvement (I hope) on progress.c:

--- progress.c.orig	2005-03-04 22:58:39.000000000 +0100
+++ progress.c	2005-03-04 23:07:13.000000000 +0100
@@ -68,9 +68,8 @@
 	if (is_last) {
 		/* Compute stats based on the starting info. */
 		diff = msdiff(&ph_start.time, now);
-		if (!diff)
-			diff = 1;
-		rate = (double) (ofs - ph_start.ofs) * 1000.0 / diff / 1024.0;
+		rate = diff ? (double) (ofs - ph_start.ofs) * 1000.0
+		    / diff / 1024.0 : 0;
 		/* Switch to total time taken for our last update. */
 		remain = (double) diff / 1000.0;
 	} else {

I don't quite see the point of setting diff to 1ms if it's zero...
Better to use the same logic as the other branch of the if statement
takes.


Paul Slootman


More information about the rsync mailing list