diff options
author | 2016-03-02 22:42:40 +0000 | |
---|---|---|
committer | 2016-03-02 22:42:40 +0000 | |
commit | cbcd819a7fd8a50c6f2880b63ad921bafa7f9638 (patch) | |
tree | 1a5a35382dd1de27dcacf7bd7c31cbd20cf5e9a0 /usr.bin/ssh/progressmeter.c | |
parent | sync (diff) | |
download | wireguard-openbsd-cbcd819a7fd8a50c6f2880b63ad921bafa7f9638.tar.xz wireguard-openbsd-cbcd819a7fd8a50c6f2880b63ad921bafa7f9638.zip |
Improve precision of progressmeter for sftp and scp by storing sub-second
timestamps. Pointed out by mmcc@, ok deraadt@ markus@
Diffstat (limited to 'usr.bin/ssh/progressmeter.c')
-rw-r--r-- | usr.bin/ssh/progressmeter.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/usr.bin/ssh/progressmeter.c b/usr.bin/ssh/progressmeter.c index 5aeaee647ed..320edff4930 100644 --- a/usr.bin/ssh/progressmeter.c +++ b/usr.bin/ssh/progressmeter.c @@ -1,4 +1,4 @@ -/* $OpenBSD: progressmeter.c,v 1.41 2015/01/14 13:54:13 djm Exp $ */ +/* $OpenBSD: progressmeter.c,v 1.42 2016/03/02 22:42:40 dtucker Exp $ */ /* * Copyright (c) 2003 Nils Nordman. All rights reserved. * @@ -61,8 +61,8 @@ void refresh_progress_meter(void); /* signal handler for updating the progress meter */ static void update_progress_meter(int); -static time_t start; /* start progress */ -static time_t last_update; /* last progress update */ +static double start; /* start progress */ +static double last_update; /* last progress update */ static const char *file; /* name of the file being transferred */ static off_t start_pos; /* initial position of transfer */ static off_t end_pos; /* ending position of transfer */ @@ -118,9 +118,8 @@ void refresh_progress_meter(void) { char buf[MAX_WINSIZE + 1]; - time_t now; off_t transferred; - double elapsed; + double elapsed, now; int percent; off_t bytes_left; int cur_speed; @@ -130,7 +129,7 @@ refresh_progress_meter(void) transferred = *counter - (cur_pos ? cur_pos : start_pos); cur_pos = *counter; - now = monotime(); + now = monotime_double(); bytes_left = end_pos - cur_pos; if (bytes_left > 0) @@ -248,7 +247,7 @@ update_progress_meter(int ignore) void start_progress_meter(const char *f, off_t filesize, off_t *ctr) { - start = last_update = monotime(); + start = last_update = monotime_double(); file = f; start_pos = *ctr; end_pos = filesize; |