commit-inetutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1-104-gac18d


From: Mats Erik Andersson
Subject: [SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1-104-gac18df3
Date: Wed, 30 May 2012 23:24:25 +0000

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  ac18df39a8502d98ebd8988937fffb98c5e405df (commit)
      from  2aea8c1ea8e0ce1f4dc173ab84dd34bd7e9782eb (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=ac18df39a8502d98ebd8988937fffb98c5e405df


commit ac18df39a8502d98ebd8988937fffb98c5e405df
Author: Mats Erik Andersson <address@hidden>
Date:   Thu May 31 00:30:27 2012 +0200

    ftpd: Adaptive block sizes.
    
    Improve throughput by use of block sizes
    as reported by file system data.

diff --git a/ChangeLog b/ChangeLog
index faabde2..2aebde6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+ 2012-05-31  Mats Erik Andersson  <address@hidden>
+
+       ftpd: Use adaptive block sizes in image mode.
+
+       * ftpd/ftpd.c (receive_data): Update signature to
+       `(FILE *, FILE *, off_t)'.  Make BUF a pointer to
+       allocated memory.
+       <TYPE_I> : Allocate BUF of size `blksize'.  Change
+       buffer size to this value inside loop calling read().
+       (retrieve): Remove `const' from BUFFER_SIZE again.
+       If `cmd == 0', use `st_blksize' for setting BUFFER_SIZE.
+       (store): Call fstat() on successful stream `fout'.
+
  2012-05-30  Mats Erik Andersson  <address@hidden>
 
        Incomplete coding of variadic printing.  Each such command
diff --git a/ftpd/ftpd.c b/ftpd/ftpd.c
index b33c246..4c1711f 100644
--- a/ftpd/ftpd.c
+++ b/ftpd/ftpd.c
@@ -248,7 +248,7 @@ static FILE *getdatasock (const char *);
 static char *gunique (const char *);
 static void lostconn (int);
 static void myoob (int);
-static int receive_data (FILE *, FILE *);
+static int receive_data (FILE *, FILE *, off_t);
 static void send_data (FILE *, FILE *, off_t);
 static void sigquit (int);
 
@@ -876,7 +876,7 @@ retrieve (const char *cmd, const char *name)
   FILE *fin, *dout;
   struct stat st;
   int (*closefunc) (FILE *);
-  const size_t buffer_size = BUFSIZ;   /* Dynamic buffer.  */
+  size_t buffer_size = BUFSIZ; /* Dynamic buffer.  */
 
   if (cmd == 0)
     {
@@ -911,6 +911,9 @@ retrieve (const char *cmd, const char *name)
       reply (550, "%s: not a plain file.", name);
       goto done;
     }
+  else if (cmd == 0)
+    buffer_size = st.st_blksize;       /* Depends on file system.  */
+
   if (restart_point)
     {
       if (type == TYPE_A)
@@ -975,7 +978,7 @@ store (const char *name, const char *mode, int unique)
     mode = "r+";
   fout = fopen (name, mode);
   closefunc = fclose;
-  if (fout == NULL)
+  if (fout == NULL || fstat (fileno (fout), &st) < 0)
     {
       perror_reply (553, name);
       LOGCMD (*mode == 'w' ? "put" : "append", name);
@@ -1020,7 +1023,7 @@ store (const char *name, const char *mode, int unique)
   din = dataconn (name, (off_t) - 1, "r");
   if (din == NULL)
     goto done;
-  if (receive_data (din, fout) == 0)
+  if (receive_data (din, fout, st.st_blksize) == 0)
     {
       if (unique)
        reply (226, "Transfer complete (unique file name:%s).", name);
@@ -1370,11 +1373,11 @@ file_err:
 
    N.B.: Form isn't handled.  */
 static int
-receive_data (FILE * instr, FILE * outstr)
+receive_data (FILE * instr, FILE * outstr, off_t blksize)
 {
   int c;
   int cnt, bare_lfs = 0;
-  char buf[BUFSIZ];
+  char *buf;
 
   transflag++;
   if (setjmp (urgcatch))
@@ -1386,12 +1389,24 @@ receive_data (FILE * instr, FILE * outstr)
     {
     case TYPE_I:
     case TYPE_L:
-      while ((cnt = read (fileno (instr), buf, sizeof (buf))) > 0)
+      buf = malloc ((u_int) blksize);
+      if (buf == NULL)
+       {
+         transflag = 0;
+         perror_reply (451, "Local resource failure: malloc");
+         return -1;
+       }
+
+      while ((cnt = read (fileno (instr), buf, blksize)) > 0)
        {
          if (write (fileno (outstr), buf, cnt) != cnt)
-           goto file_err;
+           {
+             free (buf);
+             goto file_err;
+           }
          byte_count += cnt;
        }
+      free (buf);
       if (cnt < 0)
        goto data_err;
       transflag = 0;

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog   |   13 +++++++++++++
 ftpd/ftpd.c |   31 +++++++++++++++++++++++--------
 2 files changed, 36 insertions(+), 8 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]