I noticed the "XXX: what should this be?" w.r.t. COPY_SIZE in
sftp-client.c. I made up the following quick patch to allow a new
command-line argument, "-B" (for 'buffer' size) to specify
this value.
I haven't done any strict benchmarking yet, but -B65535 is faster than
-B8192 which is much faster than -B16.
PS again, I am not on this list, so please CC me any replies.
--
Michael T. Babcock
CTO, FibreSpeed Ltd. (Hosting, Security, Consultation, Database, etc)
http://www.fibrespeed.net/~mbabcock/
-------------- next part --------------
diff -p -u openssh-3.0.2p1/scp.c openssh-3.0.2p1-mtb1/scp.c
--- openssh-3.0.2p1/scp.c Sun Oct 21 20:53:59 2001
+++ openssh-3.0.2p1-mtb1/scp.c Tue Feb 5 11:18:46 2002
@@ -966,7 +966,7 @@ void
usage()
{
(void) fprintf(stderr,
- "usage: scp [-pqrvBC46] [-F config] [-S ssh] [-P port] [-c cipher]
[-i identity]\n"
+ "usage: scp [-pqrvBC46] [-B bufsize] [-F config] [-S ssh] [-P port]
[-c cipher] [-i identity]\n"
" [-o option] f1 f2\n"
" or: scp [options] f1 ... fn directory\n");
exit(1);
diff -p -u openssh-3.0.2p1/sftp-client.c openssh-3.0.2p1-mtb1/sftp-client.c
--- openssh-3.0.2p1/sftp-client.c Wed Jul 18 11:45:45 2001
+++ openssh-3.0.2p1-mtb1/sftp-client.c Tue Feb 5 11:24:12 2002
@@ -44,7 +44,9 @@ RCSID("$OpenBSD: sftp-client.c,v 1.18 20
/* How much data to read/write at at time during copies */
/* XXX: what should this be? */
-#define COPY_SIZE 8192
+/* MTB: get around the issue by using a dynamic value with the same default. */
+/* #define COPY_SIZE 8129 */
+extern unsigned int COPY_SIZE;
/* Message ID */
static u_int msg_id = 1;
@@ -870,7 +872,11 @@ do_upload(int fd_in, int fd_out, char *l
offset = 0;
for(;;) {
int len;
- char data[COPY_SIZE];
+ char *data;
+
+ if ((data = malloc(COPY_SIZE)) == NULL)
+ fatal("Couldn't allocate %ld bytes for data buffer; %s",
+ (long)COPY_SIZE, strerror(errno));
/*
* Can't use atomicio here because it returns 0 on EOF, thus losing
diff -p -u openssh-3.0.2p1/sftp.c openssh-3.0.2p1-mtb1/sftp.c
--- openssh-3.0.2p1/sftp.c Wed Sep 19 20:57:56 2001
+++ openssh-3.0.2p1-mtb1/sftp.c Tue Feb 5 11:19:25 2002
@@ -48,6 +48,7 @@ char *__progname;
char *ssh_program = _PATH_SSH_PROGRAM;
FILE* infile;
+unsigned int COPY_SIZE=8192;
static void
connect_to_server(char **args, int *in, int *out, pid_t *sshpid)
@@ -95,7 +96,7 @@ usage(void)
{
fprintf(stderr,
"usage: sftp [-1Cv] [-b batchfile] [-F config] [-o option] [-s
subsystem|path]\n"
- " [-S program] [user@]host[:file [file]]\n");
+ " [-B bufsize] [-S program] [user@]host[:file
[file]]\n");
exit(1);
}
@@ -122,8 +123,11 @@ main(int argc, char **argv)
ll = SYSLOG_LEVEL_INFO;
infile = stdin; /* Read from STDIN unless changed by -b */
- while ((ch = getopt(argc, argv, "1hvCo:s:S:b:F:")) != -1) {
+ while ((ch = getopt(argc, argv, "1hvCo:s:S:b:F:B:")) != -1) {
switch (ch) {
+ case 'B':
+ COPY_SIZE = atoi(optarg);
+ break;
case 'C':
addargs(&args, "-C");
break;