]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
Create and use write_bigbuf() function for extra-large buffer sizes.
authorWayne Davison <wayned@samba.org>
Mon, 25 Nov 2013 21:12:35 +0000 (13:12 -0800)
committerWayne Davison <wayned@samba.org>
Mon, 25 Nov 2013 21:12:35 +0000 (13:12 -0800)
io.c
xattrs.c

diff --git a/io.c b/io.c
index c5b1ebc4c6c54a2270605c04fa4a19c108e76948..264824e70ee6be8fc92f5a302c77f23893cde6f4 100644 (file)
--- a/io.c
+++ b/io.c
@@ -2087,6 +2087,19 @@ void write_longint(int f, int64 x)
 #endif
 }
 
+void write_bigbuf(int f, const char *buf, size_t len)
+{
+       size_t half_max = (iobuf.out.size - iobuf.out_empty_len) / 2;
+
+       while (len > half_max + 1024) {
+               write_buf(f, buf, half_max);
+               buf += half_max;
+               len -= half_max;
+       }
+
+       write_buf(f, buf, len);
+}
+
 void write_buf(int f, const char *buf, size_t len)
 {
        size_t pos, siz;
index df2ea82bcbd6c9bef95731d7ed4b2e5c6d8c976f..01d30e4bfacc2e8236a3c24bba5f127ae137ee79 100644 (file)
--- a/xattrs.c
+++ b/xattrs.c
@@ -451,7 +451,7 @@ int send_xattr(int f, stat_x *sxp)
                        if (rxa->datum_len > MAX_FULL_DATUM)
                                write_buf(f, rxa->datum + 1, MAX_DIGEST_LEN);
                        else
-                               write_buf(f, rxa->datum, rxa->datum_len);
+                               write_bigbuf(f, rxa->datum, rxa->datum_len);
                }
                ndx = rsync_xal_l.count; /* pre-incremented count */
                rsync_xal_store(sxp->xattr); /* adds item to rsync_xal_l */
@@ -579,7 +579,7 @@ void send_xattr_request(const char *fname, struct file_struct *file, int f_out)
                        }
 
                        write_varint(f_out, len); /* length might have changed! */
-                       write_buf(f_out, ptr, len);
+                       write_bigbuf(f_out, ptr, len);
                        free(ptr);
                }
        }