From: Wayne Davison Date: Mon, 25 Nov 2013 21:12:35 +0000 (-0800) Subject: Create and use write_bigbuf() function for extra-large buffer sizes. X-Git-Tag: v3.1.1pre1~22 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=836e0c5df418a9fd0744e9101f05245322f8668a;p=thirdparty%2Frsync.git Create and use write_bigbuf() function for extra-large buffer sizes. --- diff --git a/io.c b/io.c index c5b1ebc4..264824e7 100644 --- 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; diff --git a/xattrs.c b/xattrs.c index df2ea82b..01d30e4b 100644 --- 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); } }