public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] gentoo-x86 commit in net-ftp/pure-ftpd/files: pure-ftpd-1.0.22-fix_rest_with_throttling.patch
@ 2009-10-22 16:07 Bernard Cafarelli (voyageur)
  0 siblings, 0 replies; only message in thread
From: Bernard Cafarelli (voyageur) @ 2009-10-22 16:07 UTC (permalink / raw
  To: gentoo-commits

voyageur    09/10/22 16:07:58

  Added:                pure-ftpd-1.0.22-fix_rest_with_throttling.patch
  Log:
  Fix REST when using throttling on mmap_send(), patch thanks to redeeman
  (Portage version: 2.2_rc46/cvs/Linux x86_64)

Revision  Changes    Path
1.1                  net-ftp/pure-ftpd/files/pure-ftpd-1.0.22-fix_rest_with_throttling.patch

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/net-ftp/pure-ftpd/files/pure-ftpd-1.0.22-fix_rest_with_throttling.patch?rev=1.1&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/net-ftp/pure-ftpd/files/pure-ftpd-1.0.22-fix_rest_with_throttling.patch?rev=1.1&content-type=text/plain

Index: pure-ftpd-1.0.22-fix_rest_with_throttling.patch
===================================================================
--- src/ftpd.c.orig	2009-10-22 16:58:51.000000000 +0200
+++ src/ftpd.c	2009-10-22 17:06:18.000000000 +0200
@@ -3096,25 +3096,23 @@
 
 int mmap_send(int f, struct stat st, double *started)
 {
-    off_t s;
     off_t skip;
     off_t o;
-    char *p, *buf;
-    off_t left;
+    char *buf;
 # ifdef THROTTLING
     double ended;
     off_t transmitted = 0;
 # endif
 
-    o = restartat & ~(map_size - 1);
-    skip = restartat - o;
+    skip = restartat % page_size;
+    o = restartat - skip;
     while (o < st.st_size) {
 # ifdef FTPWHO
         if (shm_data_cur != NULL) {
             shm_data_cur->download_current_size = o;
         }
 # endif
-        left = st.st_size - o;
+        off_t left = st.st_size - o;
         if (left > (off_t) dl_chunk_size) {
             left = (off_t) dl_chunk_size;
         }
@@ -3125,19 +3123,19 @@
             error(451, MSG_MMAP_FAILED);
             return -1;
         }
-        p = buf;
+
         o += left;
-        s = left;
+        off_t s = left;
         while (left > skip) {
             ssize_t w;
 
 # ifdef WITH_TLS
             if (enforce_tls_auth && data_protection_level == CPL_PRIVATE) {
-                w = secure_safe_write (p + skip, (size_t) (left - skip));
+                w = secure_safe_write (buf + (s - left) + skip, (size_t) left - skip );
             } else
 # endif
             {
-                while ((w = write(xferfd, p + skip, (size_t) (left - skip))) <
+                while ((w = write(xferfd, buf + (s - left) + skip, (size_t) left) - skip) <
                        (ssize_t) 0 && errno == EINTR);
             }
             if (w < (ssize_t) 0) {
@@ -3180,9 +3178,9 @@
             }
             downloaded += (unsigned long long) w;
             left -= w;
-            p += w;
+
 # ifdef THROTTLING
-            if (throttling_bandwidth_dl > 0UL) {
+            if (throttling_bandwidth_dl > 0UL && o < st.st_size) {
                 long double delay;
 
                 ended = get_usec_time();
@@ -3201,7 +3199,7 @@
             }
 # endif
         }
-        skip = (off_t) 0;
+        skip = 0;
         (void) munmap(buf, s);
     }
 






^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-10-22 16:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-22 16:07 [gentoo-commits] gentoo-x86 commit in net-ftp/pure-ftpd/files: pure-ftpd-1.0.22-fix_rest_with_throttling.patch Bernard Cafarelli (voyageur)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox