You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
3.1 KiB

  1. From 2a8f710447442e9a03e71c022859112ec2d77d17 Mon Sep 17 00:00:00 2001
  2. From: "dtucker@openbsd.org" <dtucker@openbsd.org>
  3. Date: Thu, 24 Jan 2019 16:52:17 +0000
  4. Subject: upstream: Have progressmeter force an update at the beginning and
  5. end of each transfer. Fixes the problem recently introduces where very quick
  6. transfers do not display the progressmeter at all. Spotted by naddy@
  7. OpenBSD-Commit-ID: 68dc46c259e8fdd4f5db3ec2a130f8e4590a7a9a
  8. Origin: upstream, https://anongit.mindrot.org/openssh.git/commit/?id=bdc6c63c80b55bcbaa66b5fde31c1cb1d09a41eb
  9. Last-Update: 2019-02-08
  10. Patch-Name: have-progressmeter-force-update-at-beginning-and-end-transfer.patch
  11. ---
  12. progressmeter.c | 13 +++++--------
  13. progressmeter.h | 4 ++--
  14. scp.c | 2 +-
  15. sftp-client.c | 2 +-
  16. 4 files changed, 9 insertions(+), 12 deletions(-)
  17. diff --git a/progressmeter.c b/progressmeter.c
  18. index add462dde..e385c1254 100644
  19. --- a/progressmeter.c
  20. +++ b/progressmeter.c
  21. @@ -59,9 +59,6 @@ static void format_rate(char *, int, off_t);
  22. static void sig_winch(int);
  23. static void setscreensize(void);
  24. -/* updates the progressmeter to reflect the current state of the transfer */
  25. -void refresh_progress_meter(void);
  26. -
  27. /* signal handler for updating the progress meter */
  28. static void sig_alarm(int);
  29. @@ -120,7 +117,7 @@ format_size(char *buf, int size, off_t bytes)
  30. }
  31. void
  32. -refresh_progress_meter(void)
  33. +refresh_progress_meter(int force_update)
  34. {
  35. char buf[MAX_WINSIZE + 1];
  36. off_t transferred;
  37. @@ -131,7 +128,7 @@ refresh_progress_meter(void)
  38. int hours, minutes, seconds;
  39. int file_len;
  40. - if ((!alarm_fired && !win_resized) || !can_output())
  41. + if ((!force_update && !alarm_fired && !win_resized) || !can_output())
  42. return;
  43. alarm_fired = 0;
  44. @@ -254,7 +251,7 @@ start_progress_meter(const char *f, off_t filesize, off_t *ctr)
  45. bytes_per_second = 0;
  46. setscreensize();
  47. - refresh_progress_meter();
  48. + refresh_progress_meter(1);
  49. signal(SIGALRM, sig_alarm);
  50. signal(SIGWINCH, sig_winch);
  51. @@ -271,7 +268,7 @@ stop_progress_meter(void)
  52. /* Ensure we complete the progress */
  53. if (cur_pos != end_pos)
  54. - refresh_progress_meter();
  55. + refresh_progress_meter(1);
  56. atomicio(vwrite, STDOUT_FILENO, "\n", 1);
  57. }
  58. diff --git a/progressmeter.h b/progressmeter.h
  59. index 8f6678060..1703ea75b 100644
  60. --- a/progressmeter.h
  61. +++ b/progressmeter.h
  62. @@ -24,5 +24,5 @@
  63. */
  64. void start_progress_meter(const char *, off_t, off_t *);
  65. -void refresh_progress_meter(void);
  66. +void refresh_progress_meter(int);
  67. void stop_progress_meter(void);
  68. diff --git a/scp.c b/scp.c
  69. index 80308573c..1971c80cd 100644
  70. --- a/scp.c
  71. +++ b/scp.c
  72. @@ -593,7 +593,7 @@ scpio(void *_cnt, size_t s)
  73. off_t *cnt = (off_t *)_cnt;
  74. *cnt += s;
  75. - refresh_progress_meter();
  76. + refresh_progress_meter(0);
  77. if (limit_kbps > 0)
  78. bandwidth_limit(&bwlimit, s);
  79. return 0;
  80. diff --git a/sftp-client.c b/sftp-client.c
  81. index 2bc698f86..cf2887a40 100644
  82. --- a/sftp-client.c
  83. +++ b/sftp-client.c
  84. @@ -101,7 +101,7 @@ sftpio(void *_bwlimit, size_t amount)
  85. {
  86. struct bwlimit *bwlimit = (struct bwlimit *)_bwlimit;
  87. - refresh_progress_meter();
  88. + refresh_progress_meter(0);
  89. if (bwlimit != NULL)
  90. bandwidth_limit(bwlimit, amount);
  91. return 0;