summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2014-02-26 20:48:07 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2014-02-26 20:48:07 +0000
commit6a56ede925df3442195569c2e54c1de90555310c (patch)
tree41e7b8daed2c4c532337bcef8450c52665dd95c0 /usr.bin
parent637242cc04bc402b8f59f0f703cac9823f28e92a (diff)
use a larger read buffer to speed things up, particularly during upgrades.
ok deraadt
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ftp/fetch.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/usr.bin/ftp/fetch.c b/usr.bin/ftp/fetch.c
index b88be007762..676ced935be 100644
--- a/usr.bin/ftp/fetch.c
+++ b/usr.bin/ftp/fetch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fetch.c,v 1.112 2013/12/24 13:00:59 jca Exp $ */
+/* $OpenBSD: fetch.c,v 1.113 2014/02/26 20:48:06 tedu Exp $ */
/* $NetBSD: fetch.c,v 1.14 1997/08/18 10:20:20 lukem Exp $ */
/*-
@@ -199,6 +199,7 @@ url_get(const char *origline, const char *proxyenv, const char *outfile)
SSL *ssl = NULL;
int status;
int save_errno;
+ const size_t buflen = 128 * 1024;
direction = "received";
@@ -418,13 +419,13 @@ noslash:
hashbytes = mark;
progressmeter(-1, path);
- if ((buf = malloc(4096)) == NULL)
+ if ((buf = malloc(buflen)) == NULL)
errx(1, "Can't allocate memory for transfer buffer");
/* Finally, suck down the file. */
i = 0;
oldinti = signal(SIGINFO, psummary);
- while ((len = read(s, buf, 4096)) > 0) {
+ while ((len = read(s, buf, buflen)) > 0) {
bytes += len;
for (cp = buf; len > 0; len -= i, cp += i) {
if ((i = write(out, cp, len)) == -1) {
@@ -935,13 +936,13 @@ again:
free(buf);
/* Finally, suck down the file. */
- if ((buf = malloc(4096)) == NULL)
+ if ((buf = malloc(buflen)) == NULL)
errx(1, "Can't allocate memory for transfer buffer");
i = 0;
len = 1;
oldinti = signal(SIGINFO, psummary);
while (len > 0) {
- len = ftp_read(fin, ssl, buf, 4096);
+ len = ftp_read(fin, ssl, buf, buflen);
bytes += len;
for (cp = buf, wlen = len; wlen > 0; wlen -= i, cp += i) {
if ((i = write(out, cp, wlen)) == -1) {