summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordtucker@openbsd.org <dtucker@openbsd.org>2019-01-24 16:52:17 +0000
committerDarren Tucker <dtucker@dtucker.net>2019-01-25 06:32:14 +1100
commitbdc6c63c80b55bcbaa66b5fde31c1cb1d09a41eb (patch)
treea45a5111a1f6616dd5a79544d6f0e59ca64dff30
parent258e6ca003e47f944688ad8b8de087b58a7d966c (diff)
upstream: Have progressmeter force an update at the beginning and
end of each transfer. Fixes the problem recently introduces where very quick transfers do not display the progressmeter at all. Spotted by naddy@ OpenBSD-Commit-ID: 68dc46c259e8fdd4f5db3ec2a130f8e4590a7a9a
-rw-r--r--progressmeter.c13
-rw-r--r--progressmeter.h4
-rw-r--r--scp.c4
-rw-r--r--sftp-client.c4
4 files changed, 11 insertions, 14 deletions
diff --git a/progressmeter.c b/progressmeter.c
index add462dde..e385c1254 100644
--- a/progressmeter.c
+++ b/progressmeter.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: progressmeter.c,v 1.46 2019/01/23 08:01:46 dtucker Exp $ */ 1/* $OpenBSD: progressmeter.c,v 1.47 2019/01/24 16:52:17 dtucker Exp $ */
2/* 2/*
3 * Copyright (c) 2003 Nils Nordman. All rights reserved. 3 * Copyright (c) 2003 Nils Nordman. All rights reserved.
4 * 4 *
@@ -59,9 +59,6 @@ static void format_rate(char *, int, off_t);
59static void sig_winch(int); 59static void sig_winch(int);
60static void setscreensize(void); 60static void setscreensize(void);
61 61
62/* updates the progressmeter to reflect the current state of the transfer */
63void refresh_progress_meter(void);
64
65/* signal handler for updating the progress meter */ 62/* signal handler for updating the progress meter */
66static void sig_alarm(int); 63static void sig_alarm(int);
67 64
@@ -120,7 +117,7 @@ format_size(char *buf, int size, off_t bytes)
120} 117}
121 118
122void 119void
123refresh_progress_meter(void) 120refresh_progress_meter(int force_update)
124{ 121{
125 char buf[MAX_WINSIZE + 1]; 122 char buf[MAX_WINSIZE + 1];
126 off_t transferred; 123 off_t transferred;
@@ -131,7 +128,7 @@ refresh_progress_meter(void)
131 int hours, minutes, seconds; 128 int hours, minutes, seconds;
132 int file_len; 129 int file_len;
133 130
134 if ((!alarm_fired && !win_resized) || !can_output()) 131 if ((!force_update && !alarm_fired && !win_resized) || !can_output())
135 return; 132 return;
136 alarm_fired = 0; 133 alarm_fired = 0;
137 134
@@ -254,7 +251,7 @@ start_progress_meter(const char *f, off_t filesize, off_t *ctr)
254 bytes_per_second = 0; 251 bytes_per_second = 0;
255 252
256 setscreensize(); 253 setscreensize();
257 refresh_progress_meter(); 254 refresh_progress_meter(1);
258 255
259 signal(SIGALRM, sig_alarm); 256 signal(SIGALRM, sig_alarm);
260 signal(SIGWINCH, sig_winch); 257 signal(SIGWINCH, sig_winch);
@@ -271,7 +268,7 @@ stop_progress_meter(void)
271 268
272 /* Ensure we complete the progress */ 269 /* Ensure we complete the progress */
273 if (cur_pos != end_pos) 270 if (cur_pos != end_pos)
274 refresh_progress_meter(); 271 refresh_progress_meter(1);
275 272
276 atomicio(vwrite, STDOUT_FILENO, "\n", 1); 273 atomicio(vwrite, STDOUT_FILENO, "\n", 1);
277} 274}
diff --git a/progressmeter.h b/progressmeter.h
index 8f6678060..1703ea75b 100644
--- a/progressmeter.h
+++ b/progressmeter.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: progressmeter.h,v 1.4 2019/01/23 08:01:46 dtucker Exp $ */ 1/* $OpenBSD: progressmeter.h,v 1.5 2019/01/24 16:52:17 dtucker Exp $ */
2/* 2/*
3 * Copyright (c) 2002 Nils Nordman. All rights reserved. 3 * Copyright (c) 2002 Nils Nordman. All rights reserved.
4 * 4 *
@@ -24,5 +24,5 @@
24 */ 24 */
25 25
26void start_progress_meter(const char *, off_t, off_t *); 26void start_progress_meter(const char *, off_t, off_t *);
27void refresh_progress_meter(void); 27void refresh_progress_meter(int);
28void stop_progress_meter(void); 28void stop_progress_meter(void);
diff --git a/scp.c b/scp.c
index 25595a299..74dfe521a 100644
--- a/scp.c
+++ b/scp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: scp.c,v 1.200 2019/01/23 08:01:46 dtucker Exp $ */ 1/* $OpenBSD: scp.c,v 1.201 2019/01/24 16:52:17 dtucker Exp $ */
2/* 2/*
3 * scp - secure remote copy. This is basically patched BSD rcp which 3 * scp - secure remote copy. This is basically patched BSD rcp which
4 * uses ssh to do the data transfer (instead of using rcmd). 4 * uses ssh to do the data transfer (instead of using rcmd).
@@ -588,7 +588,7 @@ scpio(void *_cnt, size_t s)
588 off_t *cnt = (off_t *)_cnt; 588 off_t *cnt = (off_t *)_cnt;
589 589
590 *cnt += s; 590 *cnt += s;
591 refresh_progress_meter(); 591 refresh_progress_meter(0);
592 if (limit_kbps > 0) 592 if (limit_kbps > 0)
593 bandwidth_limit(&bwlimit, s); 593 bandwidth_limit(&bwlimit, s);
594 return 0; 594 return 0;
diff --git a/sftp-client.c b/sftp-client.c
index 36c4b8a4a..73e3c2f53 100644
--- a/sftp-client.c
+++ b/sftp-client.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sftp-client.c,v 1.132 2019/01/23 08:01:46 dtucker Exp $ */ 1/* $OpenBSD: sftp-client.c,v 1.133 2019/01/24 16:52:17 dtucker Exp $ */
2/* 2/*
3 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> 3 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
4 * 4 *
@@ -102,7 +102,7 @@ sftpio(void *_bwlimit, size_t amount)
102{ 102{
103 struct bwlimit *bwlimit = (struct bwlimit *)_bwlimit; 103 struct bwlimit *bwlimit = (struct bwlimit *)_bwlimit;
104 104
105 refresh_progress_meter(); 105 refresh_progress_meter(0);
106 if (bwlimit != NULL) 106 if (bwlimit != NULL)
107 bandwidth_limit(bwlimit, amount); 107 bandwidth_limit(bwlimit, amount);
108 return 0; 108 return 0;