Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/ftp * add support for `xferbuf', which sets both `sn...
details: https://anonhg.NetBSD.org/src/rev/d7c2ba187b1c
branches: trunk
changeset: 476622:d7c2ba187b1c
user: lukem <lukem%NetBSD.org@localhost>
date: Wed Sep 22 07:18:31 1999 +0000
description:
* add support for `xferbuf', which sets both `sndbuf' and `rcvbuf'
* document the above three commands
* rototill the way the sndbuf and rcvbuf work. remove resetsockbufsize()
* use the appropriate socket buffer size as the size of the buffer that
the read()/write() loops use. speeds up things in some cases.
diffstat:
usr.bin/ftp/cmds.c | 79 ++++++++++++++++++++------------------------------
usr.bin/ftp/cmdtab.c | 12 +++---
usr.bin/ftp/extern.h | 6 +--
usr.bin/ftp/fetch.c | 35 ++++++++++++++--------
usr.bin/ftp/ftp.1 | 21 +++++++++---
usr.bin/ftp/ftp.c | 47 ++++++++++++++++++------------
usr.bin/ftp/ftp_var.h | 6 +---
usr.bin/ftp/main.c | 25 ++++++++++++++-
usr.bin/ftp/util.c | 54 +++++-----------------------------
9 files changed, 136 insertions(+), 149 deletions(-)
diffs (truncated from 654 to 300 lines):
diff -r 280afcb960a8 -r d7c2ba187b1c usr.bin/ftp/cmds.c
--- a/usr.bin/ftp/cmds.c Wed Sep 22 07:15:43 1999 +0000
+++ b/usr.bin/ftp/cmds.c Wed Sep 22 07:18:31 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cmds.c,v 1.57 1999/09/22 03:01:53 lukem Exp $ */
+/* $NetBSD: cmds.c,v 1.58 1999/09/22 07:18:31 lukem Exp $ */
/*
* Copyright (C) 1997 and 1998 WIDE Project.
@@ -107,7 +107,7 @@
#if 0
static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94";
#else
-__RCSID("$NetBSD: cmds.c,v 1.57 1999/09/22 03:01:53 lukem Exp $");
+__RCSID("$NetBSD: cmds.c,v 1.58 1999/09/22 07:18:31 lukem Exp $");
#endif
#endif /* not lint */
@@ -762,6 +762,9 @@
fprintf(ttyout,
"Put transfer rate throttle: %s; maximum: %d; increment %d.\n",
onoff(rate_put), rate_put, rate_put_incr);
+ fprintf(ttyout,
+ "Socket buffer sizes: send %d, receive %d.\n",
+ sndbuf_size, rcvbuf_size);
fprintf(ttyout, "Use of PORT cmds: %s.\n", onoff(sendport));
fprintf(ttyout, "Use of EPSV/EPRT cmds for IPv4: %s.\n", onoff(epsv4));
#ifndef NO_EDITCOMPLETE
@@ -1669,8 +1672,6 @@
if (!proxy) {
macnum = 0;
}
-
- resetsockbufsize();
}
void
@@ -2418,62 +2419,46 @@
}
/*
- * Set the socket send buffer size.
+ * Set the socket send or receive buffer size.
*/
void
-sndbuf(argc, argv)
+setxferbuf(argc, argv)
int argc;
char *argv[];
{
- int size;
+ int size, dir;
if (argc != 2) {
- printf("usage: %s size\n", argv[0]);
- code = -1;
- return;
- }
-
- if ((size = strsuftoi(argv[1])) == -1) {
- printf("invalid socket buffer size: %s\n", argv[1]);
+ usage:
+ fprintf(ttyout, "usage: %s size\n", argv[0]);
code = -1;
return;
}
+ if (strcasecmp(argv[0], "sndbuf") == 0)
+ dir = RATE_PUT;
+ else if (strcasecmp(argv[0], "rcvbuf") == 0)
+ dir = RATE_GET;
+ else if (strcasecmp(argv[0], "xferbuf") == 0)
+ dir = RATE_ALL;
+ else
+ goto usage;
- sndbuf_size = size;
- if (sndbuf_size)
- sndbuf_manual = 1;
- else
- sndbuf_manual = 0;
+ if ((size = strsuftoi(argv[1])) == -1)
+ goto usage;
+
+ if (size == 0) {
+ fprintf(ttyout, "%s: size must be positive.\n", argv[0]);
+ goto usage;
+ }
+
+ if (dir & RATE_PUT)
+ sndbuf_size = size;
+ if (dir & RATE_GET)
+ rcvbuf_size = size;
+ fprintf(ttyout, "Socket buffer sizes: send %d, receive %d.\n",
+ sndbuf_size, rcvbuf_size);
}
-/*
- * Set the socket receive buffer size.
- */
-void
-rcvbuf(argc, argv)
- int argc;
- char *argv[];
-{
- int size;
-
- if (argc != 2) {
- printf("usage: %s size\n", argv[0]);
- code = -1;
- return;
- }
-
- if ((size = strsuftoi(argv[1])) == -1) {
- printf("invalid socket buffer size: %s\n", argv[1]);
- code = -1;
- return;
- }
-
- rcvbuf_size = size;
- if (rcvbuf_size)
- rcvbuf_manual = 1;
- else
- rcvbuf_manual = 0;
-}
void
setepsv4(argc, argv)
diff -r 280afcb960a8 -r d7c2ba187b1c usr.bin/ftp/cmdtab.c
--- a/usr.bin/ftp/cmdtab.c Wed Sep 22 07:15:43 1999 +0000
+++ b/usr.bin/ftp/cmdtab.c Wed Sep 22 07:18:31 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cmdtab.c,v 1.25 1999/07/11 20:37:39 itojun Exp $ */
+/* $NetBSD: cmdtab.c,v 1.26 1999/09/22 07:18:32 lukem Exp $ */
/*
* Copyright (c) 1985, 1989, 1993, 1994
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)cmdtab.c 8.4 (Berkeley) 10/9/94";
#else
-__RCSID("$NetBSD: cmdtab.c,v 1.25 1999/07/11 20:37:39 itojun Exp $");
+__RCSID("$NetBSD: cmdtab.c,v 1.26 1999/09/22 07:18:32 lukem Exp $");
#endif
#endif /* not lint */
@@ -104,7 +104,6 @@
char quithelp[] = "terminate ftp session and exit";
char quotehelp[] = "send arbitrary ftp command";
char ratehelp[] = "set transfer rate limit";
-char rcvbufhelp[] = "set socket receive buffer size";
char receivehelp[] = "receive file";
char regethelp[] = "get file restarting at end of local file";
char remotehelp[] = "get help from remote server";
@@ -120,7 +119,6 @@
"\t\tTry \"rhelp site\" or \"site help\" "
"for more information";
char sizecmdhelp[] = "show size of remote file";
-char sndbufhelp[] = "set socket send buffer size";
char statushelp[] = "show current status";
char structhelp[] = "set file transfer structure";
char suniquehelp[] = "toggle store unique on remote machine";
@@ -131,6 +129,7 @@
char umaskhelp[] = "get (set) umask on remote side";
char userhelp[] = "send new user information";
char verbosehelp[] = "toggle verbose mode";
+char xferbufhelp[] = "set socket send/receive buffer size";
#ifdef NO_EDITCOMPLETE
#define CMPL(x)
@@ -204,7 +203,7 @@
{ "quit", quithelp, 0, 0, 0, CMPL0 quit },
{ "quote", quotehelp, 1, 1, 1, CMPL0 quote },
{ "rate", ratehelp, 0, 0, 0, CMPL0 setrate },
- { "rcvbuf", rcvbufhelp, 0, 0, 0, CMPL0 rcvbuf },
+ { "rcvbuf", xferbufhelp, 0, 0, 0, CMPL0 setxferbuf },
{ "recv", receivehelp, 1, 1, 1, CMPL(rl) get },
{ "reget", regethelp, 1, 1, 1, CMPL(rl) reget },
{ "rename", renamehelp, 0, 1, 1, CMPL(rr) renamefile },
@@ -218,7 +217,7 @@
{ "sendport", porthelp, 0, 0, 0, CMPL0 setport },
{ "site", sitehelp, 0, 1, 1, CMPL0 site },
{ "size", sizecmdhelp, 1, 1, 1, CMPL(r) sizecmd },
- { "sndbuf", sndbufhelp, 0, 0, 0, CMPL0 sndbuf },
+ { "sndbuf", xferbufhelp, 0, 0, 0, CMPL0 setxferbuf },
{ "status", statushelp, 0, 0, 1, CMPL0 status },
{ "struct", structhelp, 0, 1, 1, CMPL0 setstruct },
{ "sunique", suniquehelp, 0, 0, 1, CMPL0 setsunique },
@@ -230,6 +229,7 @@
{ "umask", umaskhelp, 0, 1, 1, CMPL0 do_umask },
{ "user", userhelp, 0, 1, 1, CMPL0 user },
{ "verbose", verbosehelp, 0, 0, 0, CMPL0 setverbose },
+ { "xferbuf", xferbufhelp, 0, 0, 0, CMPL0 setxferbuf },
{ "?", helphelp, 0, 0, 1, CMPL(C) help },
{ 0 },
};
diff -r 280afcb960a8 -r d7c2ba187b1c usr.bin/ftp/extern.h
--- a/usr.bin/ftp/extern.h Wed Sep 22 07:15:43 1999 +0000
+++ b/usr.bin/ftp/extern.h Wed Sep 22 07:18:31 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.34 1999/07/12 13:20:34 lukem Exp $ */
+/* $NetBSD: extern.h,v 1.35 1999/09/22 07:18:32 lukem Exp $ */
/*
* Copyright (C) 1997 and 1998 WIDE Project.
@@ -144,7 +144,6 @@
void quit __P((int, char **));
void quote __P((int, char **));
void quote1 __P((const char *, int, char **));
-void rcvbuf __P((int, char **));
void recvrequest __P((const char *, const char *, const char *,
const char *, int, int));
void reget __P((int, char **));
@@ -154,7 +153,6 @@
void removedir __P((int, char **));
void renamefile __P((int, char **));
void reset __P((int, char **));
-void resetsockbufsize __P((void));
void restart __P((int, char **));
void rmthelp __P((int, char **));
void rmtstatus __P((int, char **));
@@ -192,11 +190,11 @@
void settype __P((int, char **));
void setupsockbufsize __P((int));
void setverbose __P((int, char **));
+void setxferbuf __P((int, char **));
void shell __P((int, char **));
void site __P((int, char **));
void sizecmd __P((int, char **));
char *slurpstring __P((void));
-void sndbuf __P((int, char **));
void status __P((int, char **));
int strsuftoi __P((const char *));
void syst __P((int, char **));
diff -r 280afcb960a8 -r d7c2ba187b1c usr.bin/ftp/fetch.c
--- a/usr.bin/ftp/fetch.c Wed Sep 22 07:15:43 1999 +0000
+++ b/usr.bin/ftp/fetch.c Wed Sep 22 07:18:31 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fetch.c,v 1.72 1999/09/22 03:01:53 lukem Exp $ */
+/* $NetBSD: fetch.c,v 1.73 1999/09/22 07:18:33 lukem Exp $ */
/*-
* Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: fetch.c,v 1.72 1999/09/22 03:01:53 lukem Exp $");
+__RCSID("$NetBSD: fetch.c,v 1.73 1999/09/22 07:18:33 lukem Exp $");
#endif /* not lint */
/*
@@ -445,6 +445,8 @@
volatile int s;
int ischunked, isproxy, rval, hcode;
size_t len;
+ static size_t bufsize;
+ static char *xferbuf;
char *cp, *ep, *buf, *savefile;
char *auth, *location, *message;
char *user, *pass, *host, *port, *path, *decodedpath;
@@ -1048,23 +1050,31 @@
}
oldintr = signal(SIGINT, aborthttp);
+ if (rcvbuf_size > bufsize) {
+ if (xferbuf)
+ (void)free(xferbuf);
+ bufsize = rcvbuf_size;
+ xferbuf = xmalloc(bufsize);
+ }
+ if (debug)
+ fprintf(ttyout, "using a buffer size of %d\n", (int)bufsize);
+
bytes = 0;
hashbytes = mark;
progressmeter(-1);
/* Finally, suck down the file. */
- buf = xmalloc(BUFSIZ + 1);
do {
ssize_t chunksize;
chunksize = 0;
/* read chunksize */
if (ischunked) {
- if (fgets(buf, BUFSIZ, fin) == NULL) {
+ if (fgets(xferbuf, bufsize, fin) == NULL) {
warnx("Unexpected EOF reading chunksize");
goto cleanup_fetch_url;
}
- chunksize = strtol(buf, &ep, 16);
+ chunksize = strtol(xferbuf, &ep, 16);
if (strcmp(ep, "\r\n") != 0) {
warnx("Unexpected data following chunksize");
goto cleanup_fetch_url;
@@ -1088,16 +1098,16 @@
if (rate_get)
(void)gettimeofday(&then, NULL);
- bufrem = rate_get ? rate_get : BUFSIZ;
Home |
Main Index |
Thread Index |
Old Index