This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".
The branch, master has been updated
via 890be117d428028e4e77608303416598c163c158 (commit)
from ac18df39a8502d98ebd8988937fffb98c5e405df (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=890be117d428028e4e77608303416598c163c158
commit 890be117d428028e4e77608303416598c163c158
Author: Mats Erik Andersson <[email protected]>
Date: Thu May 31 17:13:41 2012 +0200
ftp: Adaptive block size.
diff --git a/ChangeLog b/ChangeLog
index 2aebde6..9f72a57 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
2012-05-31 Mats Erik Andersson <[email protected]>
+ ftp: Adaptive block size in image mode.
+
+ * ftp/ftp.c (sendrequest): New variables BLKSIZE, BUFSIZE.
+ Change type of BUF to `static char *' for allocation.
+ Set BLKSIZE to `st_blksize' for input file. Allocate and
+ increase size of buffer as needed.
+ <TYPE_I>: Use BUFSIZE for buffer length when calling read().
+ (recvrequest): Call fstat() on successful stream `fout'
+ and set BLKSIZE to `st_blksize'.
+ (abort_remote): Replace macro BUFSIZ by `sizeof(buf)'.
+
+ 2012-05-31 Mats Erik Andersson <[email protected]>
+
ftpd: Use adaptive block sizes in image mode.
* ftpd/ftpd.c (receive_data): Update signature to
diff --git a/ftp/ftp.c b/ftp/ftp.c
index b662259..3317055 100644
--- a/ftp/ftp.c
+++ b/ftp/ftp.c
@@ -542,7 +542,10 @@ sendrequest (char *cmd, char *local, char *remote, int
printnames)
int (*closefunc) (FILE *);
sighandler_t oldintr, oldintp;
long long bytes = 0, local_hashbytes = hashbytes;
- char *lmode, buf[BUFSIZ], *bufp;
+ char *lmode, *bufp;
+ int blksize = BUFSIZ;
+ static int bufsize = 0;
+ static char *buf;
if (verbose && printnames)
{
@@ -616,6 +619,7 @@ sendrequest (char *cmd, char *local, char *remote, int
printnames)
code = -1;
return;
}
+ blksize = st.st_blksize;
}
if (initconn ())
{
@@ -687,6 +691,20 @@ sendrequest (char *cmd, char *local, char *remote, int
printnames)
dout = dataconn (lmode);
if (dout == NULL)
goto abort;
+
+ if (blksize > bufsize)
+ {
+ free (buf);
+ buf = malloc ((unsigned) blksize);
+ if (buf == NULL)
+ {
+ error (0, errno, "malloc");
+ bufsize = 0;
+ goto abort;
+ }
+ bufsize = blksize;
+ }
+
gettimeofday (&start, (struct timezone *) 0);
oldintp = signal (SIGPIPE, SIG_IGN);
switch (curtype)
@@ -695,7 +713,7 @@ sendrequest (char *cmd, char *local, char *remote, int
printnames)
case TYPE_I:
case TYPE_L:
errno = d = 0;
- while ((c = read (fileno (fin), buf, sizeof (buf))) > 0)
+ while ((c = read (fileno (fin), buf, bufsize)) > 0)
{
bytes += c;
for (bufp = buf; c > 0; c -= d, bufp += d)
@@ -823,7 +841,8 @@ recvrequest (char *cmd, char *local, char *remote, char
*lmode, int printnames)
FILE *fout, *din = 0;
int (*closefunc) (FILE *);
sighandler_t oldintr, oldintp;
- int c, d, is_retr, tcrflag, bare_lfs = 0, blksize;
+ int c, d, is_retr, tcrflag, bare_lfs = 0;
+ int blksize = BUFSIZ;
static int bufsize = 0;
static char *buf;
long long bytes = 0, local_hashbytes = hashbytes;
@@ -909,6 +928,7 @@ recvrequest (char *cmd, char *local, char *remote, char
*lmode, int printnames)
din = dataconn ("r");
if (din == NULL)
goto abort;
+
if (strcmp (local, "-") == 0)
fout = stdout;
else if (*local == '|')
@@ -924,15 +944,18 @@ recvrequest (char *cmd, char *local, char *remote, char
*lmode, int printnames)
}
else
{
+ struct stat st;
+
fout = fopen (local, lmode);
- if (fout == NULL)
+ if (fout == NULL || fstat (fileno (fout), &st) < 0)
{
error (0, errno, "local: %s", local);
goto abort;
}
closefunc = fclose;
+ blksize = st.st_blksize;
}
- blksize = BUFSIZ;
+
if (blksize > bufsize)
{
free (buf);
@@ -945,6 +968,7 @@ recvrequest (char *cmd, char *local, char *remote, char
*lmode, int printnames)
}
bufsize = blksize;
}
+
gettimeofday (&start, (struct timezone *) 0);
switch (curtype)
{
@@ -974,6 +998,7 @@ recvrequest (char *cmd, char *local, char *remote, char
*lmode, int printnames)
fflush (stdout);
}
}
+
if (hash && bytes > 0)
{
if (bytes < local_hashbytes)
@@ -1891,7 +1916,7 @@ abort_remote (FILE *din)
}
if (din && FD_ISSET (fileno (din), &mask))
{
- while (read (fileno (din), buf, BUFSIZ) > 0)
+ while (read (fileno (din), buf, sizeof (buf)) > 0)
/* LOOP */ ;
}
if (getreply (0) == ERROR && code == 552)
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 13 +++++++++++++
ftp/ftp.c | 37 +++++++++++++++++++++++++++++++------
2 files changed, 44 insertions(+), 6 deletions(-)
hooks/post-receive
--
GNU Inetutils
_______________________________________________
Commit-inetutils mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/commit-inetutils