Switch to flow-control-based SFTP uploading.

Formerly PuTTY's SFTP code would transmit (or buffer) a megabyte of data
before even starting to look for acknowledgements, but wouldn't allow
there to be more than a megabyte of unacknowledged data at a time.  Now,
instead, it pays attention to whether the transmit path is blocked, and
transmits iff it isn't.

This should mean that SFTP goes faster over long fat pipes, and also
doesn't end up buffering so much over thin ones.

I practice, I tend to run into other performance limitations (such as
TCP or SSH-2 windows) before this enhancement looks particularly good,
but with an artificial lag of 250 ms on the loopback interface this
patch almost doubles my upload speed, so I think it's worthwhile.
This commit is contained in:
Ben Harris 2016-04-09 00:24:12 +01:00
Родитель cb36668185
Коммит 5c42f97b68
4 изменённых файлов: 13 добавлений и 1 удалений

4
pscp.c
Просмотреть файл

@ -658,6 +658,10 @@ int sftp_senddata(char *buf, int len)
back->send(backhandle, buf, len);
return 1;
}
int sftp_sendbuffer(void)
{
return back->sendbuffer(backhandle);
}
/* ----------------------------------------------------------------------
* sftp-based replacement for the hacky `pscp -ls'.

Просмотреть файл

@ -2618,6 +2618,10 @@ int sftp_senddata(char *buf, int len)
back->send(backhandle, buf, len);
return 1;
}
int sftp_sendbuffer(void)
{
return back->sendbuffer(backhandle);
}
/*
* Short description of parameters.

2
sftp.c
Просмотреть файл

@ -1349,7 +1349,7 @@ struct fxp_xfer *xfer_upload_init(struct fxp_handle *fh, uint64 offset)
int xfer_upload_ready(struct fxp_xfer *xfer)
{
if (xfer->req_totalsize < xfer->req_maxsize)
if (sftp_sendbuffer() == 0)
return 1;
else
return 0;

4
sftp.h
Просмотреть файл

@ -63,8 +63,12 @@
* until len is available, or it returns failure.
*
* Both functions return 1 on success, 0 on failure.
*
* sftp_sendbuffer returns the size of the backlog of data in the
* transmit queue.
*/
int sftp_senddata(char *data, int len);
int sftp_sendbuffer(void);
int sftp_recvdata(char *data, int len);
/*