bin/62696: ssh: progress meter shows wonky throughput

Christian Weisgerber naddy at FreeBSD.org
Wed Feb 11 09:10:22 PST 2004


>Number:         62696
>Category:       bin
>Synopsis:       ssh: progress meter shows wonky throughput
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Feb 11 09:10:22 PST 2004
>Closed-Date:
>Last-Modified:
>Originator:     Christian Weisgerber
>Release:        FreeBSD 5.2-CURRENT alpha
>Organization:
>Environment:
System: FreeBSD kemoauc.mips.inka.de 5.2-CURRENT FreeBSD 5.2-CURRENT #0: Mon Feb 9 20:54:04 CET 2004 root@:/usr/src/sys/alpha/compile/KEMOAUC alpha

>Description:

scp's progress meter sometimes reports wrong throughput figures.
When I transfer a 3GB backup file between two of my machines, the
initially indicated throughput (~2.2MB/s) is plausible.  As the
transfer progresses, the displayed throughput keeps diminishing,
eventually getting as low as single-digit _k_B/s figures.  Meanwhile,
the progress meter also shows the total transferred amount incrementing
by 2MB every second.  Eventually the throughput figure jumps up
again to plausible values but occasionally reverts to absurd figures.

Actual throughput is constant at (in this case) 2.xMB/s, it's clearly
the progress meter that's at fault.

>How-To-Repeat:

>Fix:

Update progressmeter.c to the current revision 1.19 from the OpenBSD
CVS, which should cure several bugs, judging from the commit log.

Index: progressmeter.c
===================================================================
RCS file: /home/ncvs/src/crypto/openssh/progressmeter.c,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 progressmeter.c
--- progressmeter.c	9 Jan 2004 12:57:36 -0000	1.1.1.3
+++ progressmeter.c	11 Feb 2004 16:12:16 -0000
@@ -23,7 +23,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: progressmeter.c,v 1.15 2003/08/31 12:14:22 markus Exp $");
+RCSID("$OpenBSD: progressmeter.c,v 1.19 2004/02/05 15:33:33 markus Exp $");
 
 #include "progressmeter.h"
 #include "atomicio.h"
@@ -80,7 +80,7 @@
 		bytes = (bytes + 512) / 1024;
 	}
 	snprintf(buf, size, "%3lld.%1lld%c%s",
-	    (int64_t) bytes / 100,
+	    (int64_t) (bytes + 5) / 100,
 	    (int64_t) (bytes + 5) / 10 % 10,
 	    unit[i],
 	    i ? "B" : " ");
@@ -107,7 +107,7 @@
 	off_t transferred;
 	double elapsed;
 	int percent;
-	int bytes_left;
+	off_t bytes_left;
 	int cur_speed;
 	int hours, minutes, seconds;
 	int i, len;
@@ -120,14 +120,18 @@
 
 	if (bytes_left > 0)
 		elapsed = now - last_update;
-	else
+	else {
 		elapsed = now - start;
+		/* Calculate true total speed when done */
+		transferred = end_pos;
+		bytes_per_second = 0;
+	}
 
 	/* calculate speed */
 	if (elapsed != 0)
 		cur_speed = (transferred / elapsed);
 	else
-		cur_speed = 0;
+		cur_speed = transferred;
 
 #define AGE_FACTOR 0.9
 	if (bytes_per_second != 0) {
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list