aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authorWayne Davison <wayned@samba.org>2006-02-04 21:52:32 +0000
committerWayne Davison <wayned@samba.org>2006-02-04 21:52:32 +0000
commit12bda6f7106a57a05f5b0b25fc82b48f78e4cfb0 (patch)
tree6adf61fdf788d399ff6ec6221e429ab3b86518ac /io.c
parentc53b6fd0ac7f0364fc454bc19647aa5b843d7848 (diff)
downloadandroid_external_rsync-12bda6f7106a57a05f5b0b25fc82b48f78e4cfb0.tar.gz
android_external_rsync-12bda6f7106a57a05f5b0b25fc82b48f78e4cfb0.tar.bz2
android_external_rsync-12bda6f7106a57a05f5b0b25fc82b48f78e4cfb0.zip
Don't do so much memory copying in mplex_write().
Diffstat (limited to 'io.c')
-rw-r--r--io.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/io.c b/io.c
index 6dafa2af..dd99913d 100644
--- a/io.c
+++ b/io.c
@@ -774,12 +774,13 @@ static int readfd_unbuffered(int fd, char *buf, size_t len)
if (msg_bytes >= sizeof line)
goto overflow;
read_loop(fd, line, msg_bytes);
- line[msg_bytes] = '\0';
/* A directory name was sent with the trailing null */
if (msg_bytes > 0 && !line[msg_bytes-1])
log_delete(line, S_IFDIR);
- else
+ else {
+ line[msg_bytes] = '\0';
log_delete(line, S_IFREG);
+ }
break;
case MSG_SUCCESS:
if (msg_bytes != 4) {
@@ -1111,7 +1112,7 @@ static void writefd_unbuffered(int fd,char *buf,size_t len)
**/
static void mplex_write(enum msgcode code, char *buf, size_t len)
{
- char buffer[BIGPATHBUFLEN];
+ char buffer[1024];
size_t n = len;
SIVAL(buffer, 0, ((MPLEX_BASE + (int)code)<<24) + len);
@@ -1124,9 +1125,10 @@ static void mplex_write(enum msgcode code, char *buf, size_t len)
contiguous_write_len = len + 4;
if (n > sizeof buffer - 4)
- n = sizeof buffer - 4;
+ n = 0;
+ else
+ memcpy(buffer + 4, buf, n);
- memcpy(&buffer[4], buf, n);
writefd_unbuffered(sock_f_out, buffer, n+4);
len -= n;