diff options
author | jmz <jmz@FreeBSD.org> | 1996-07-05 00:06:36 +0000 |
---|---|---|
committer | jmz <jmz@FreeBSD.org> | 1996-07-05 00:06:36 +0000 |
commit | 557b0ffde9d2527303741bfbf73df79268897bc5 (patch) | |
tree | 3cf063fa27d4788f13f65f1a0bdc1e0049c309d6 /usr.bin | |
parent | 65878e4c921bba27a5b3633898ce21e49043f98f (diff) | |
download | FreeBSD-src-557b0ffde9d2527303741bfbf73df79268897bc5.zip FreeBSD-src-557b0ffde9d2527303741bfbf73df79268897bc5.tar.gz |
Back out previous commit: do not use read(), but fread (). Change BUFFER_SIZE
to 1K to avoid waiting too long between 2 progress reports in the case of a
slow transfer.
Move the signal()/setitimer() code just before the read loop because the
ftpio library set and reset the timer internally.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/fetch/main.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/usr.bin/fetch/main.c b/usr.bin/fetch/main.c index 5ed7a6c..389384d 100644 --- a/usr.bin/fetch/main.c +++ b/usr.bin/fetch/main.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. */ -/* $Id: main.c,v 1.6 1996/06/25 21:33:18 ache Exp $ */ +/* $Id: main.c,v 1.7 1996/07/02 01:49:47 jmz Exp $ */ #include <stdlib.h> #include <stdio.h> @@ -46,7 +46,7 @@ #include <ftpio.h> -#define BUFFER_SIZE 32*1024 +#define BUFFER_SIZE 1024 #define HTTP_TIMEOUT 60 /* seconds */ #define FTP_TIMEOUT 300 /* seconds */ @@ -208,14 +208,6 @@ ftpget () time_t t; struct itimerval timer; - signal (SIGALRM, t_out); - if ((cp = getenv("FTP_TIMEOUT")) != NULL) - timer.it_interval.tv_sec = timer.it_value.tv_sec = atoi(cp); - else - timer.it_interval.tv_sec = timer.it_value.tv_sec = FTP_TIMEOUT; - timer.it_interval.tv_usec = timer.it_value.tv_usec = 0; - setitimer(ITIMER_REAL, &timer, 0); - if ((cp = getenv("FTP_PASSWORD")) != NULL) strcpy(ftp_pw, cp); else { @@ -279,9 +271,17 @@ ftpget () } else file = stdout; + signal (SIGALRM, t_out); + if ((cp = getenv("FTP_TIMEOUT")) != NULL) + timer.it_interval.tv_sec = timer.it_value.tv_sec = atoi(cp); + else + timer.it_interval.tv_sec = timer.it_value.tv_sec = FTP_TIMEOUT; + timer.it_interval.tv_usec = timer.it_value.tv_usec = 0; + setitimer(ITIMER_REAL, &timer, 0); + display (size, size0); while (1) { - n = status = read (fileno (fp), buffer, BUFFER_SIZE); + n = status = fread (buffer, 1, BUFFER_SIZE, fp); if (status <= 0) break; display (size, n); |