summaryrefslogtreecommitdiff
path: root/progressmeter.c
diff options
context:
space:
mode:
authordtucker@openbsd.org <dtucker@openbsd.org>2016-03-02 22:42:40 +0000
committerDamien Miller <djm@mindrot.org>2016-03-04 15:12:19 +1100
commitb8d4eafe29684fe4f5bb587f7eab948e6ed62723 (patch)
tree3bdc08a366a144ea37ee94907d62f21fa52d2f53 /progressmeter.c
parent18f64b969c70ed00e74b9d8e50359dbe698ce4c0 (diff)
upstream commit
Improve precision of progressmeter for sftp and scp by storing sub-second timestamps. Pointed out by mmcc@, ok deraadt@ markus@ Upstream-ID: 38fd83a3d83dbf81c8ff7b5d1302382fe54970ab
Diffstat (limited to 'progressmeter.c')
-rw-r--r--progressmeter.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/progressmeter.c b/progressmeter.c
index 319b7470a..3a455408c 100644
--- a/progressmeter.c
+++ b/progressmeter.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: progressmeter.c,v 1.41 2015/01/14 13:54:13 djm Exp $ */ 1/* $OpenBSD: progressmeter.c,v 1.42 2016/03/02 22:42:40 dtucker Exp $ */
2/* 2/*
3 * Copyright (c) 2003 Nils Nordman. All rights reserved. 3 * Copyright (c) 2003 Nils Nordman. All rights reserved.
4 * 4 *
@@ -63,8 +63,8 @@ void refresh_progress_meter(void);
63/* signal handler for updating the progress meter */ 63/* signal handler for updating the progress meter */
64static void update_progress_meter(int); 64static void update_progress_meter(int);
65 65
66static time_t start; /* start progress */ 66static double start; /* start progress */
67static time_t last_update; /* last progress update */ 67static double last_update; /* last progress update */
68static const char *file; /* name of the file being transferred */ 68static const char *file; /* name of the file being transferred */
69static off_t start_pos; /* initial position of transfer */ 69static off_t start_pos; /* initial position of transfer */
70static off_t end_pos; /* ending position of transfer */ 70static off_t end_pos; /* ending position of transfer */
@@ -120,9 +120,8 @@ void
120refresh_progress_meter(void) 120refresh_progress_meter(void)
121{ 121{
122 char buf[MAX_WINSIZE + 1]; 122 char buf[MAX_WINSIZE + 1];
123 time_t now;
124 off_t transferred; 123 off_t transferred;
125 double elapsed; 124 double elapsed, now;
126 int percent; 125 int percent;
127 off_t bytes_left; 126 off_t bytes_left;
128 int cur_speed; 127 int cur_speed;
@@ -132,7 +131,7 @@ refresh_progress_meter(void)
132 131
133 transferred = *counter - (cur_pos ? cur_pos : start_pos); 132 transferred = *counter - (cur_pos ? cur_pos : start_pos);
134 cur_pos = *counter; 133 cur_pos = *counter;
135 now = monotime(); 134 now = monotime_double();
136 bytes_left = end_pos - cur_pos; 135 bytes_left = end_pos - cur_pos;
137 136
138 if (bytes_left > 0) 137 if (bytes_left > 0)
@@ -250,7 +249,7 @@ update_progress_meter(int ignore)
250void 249void
251start_progress_meter(const char *f, off_t filesize, off_t *ctr) 250start_progress_meter(const char *f, off_t filesize, off_t *ctr)
252{ 251{
253 start = last_update = monotime(); 252 start = last_update = monotime_double();
254 file = f; 253 file = f;
255 start_pos = *ctr; 254 start_pos = *ctr;
256 end_pos = filesize; 255 end_pos = filesize;