[patch] output of rsync -n truncated
Dick Streefland
dick.streefland at altium.nl
Thu May 16 03:01:02 EST 2002
I noticed that the output of "rsync -n" is sometimes truncated.
Even when you repeat the same command, the output may be different.
I'm using rsync-2.5.5 on a Debian woody system with ext3 file systems.
One scenario to reproduce this behavior is someting like this:
# rsync -aR /usr/share/zoneinfo /tmp
# rsync -n -avRH localhost:/usr/share/zoneinfo /tmp
receiving file list ... done
usr/share/zoneinfo/Asia/Dhaka => usr/share/zoneinfo/Asia/Dacca
usr/share/zoneinfo/Asia/Thimphu => usr/share/zoneinfo/Asia/Thimbu
usr/share/zoneinfo/PRC => usr/share/zoneinfo/Asia/Shanghai
usr/share/zoneinfo/Asia/Chungking => usr/share/zoneinfo/Asia/Chongqing
usr/share/zoneinfo/Hongkong => usr/share/zoneinfo/Asia/Hong_Kong
usr/share/zoneinfo/ROC => usr/share/zoneinfo/Asia/Taipei
[...]
wrote 16 bytes read 37138 bytes 24769.33 bytes/sec
total size is 865270 speedup is 23.29
# rsync -n -avRH /usr/share/zoneinfo /tmp
building file list ... done
usr/share/zoneinfo/Asia/Dhaka => usr/share/zoneinfo/Asia/Dacca
usr/share/zoneinfo/Asia/Thimphu => usr/share/zoneinfo/Asia/Thimbu
wrote 37134 bytes read 20 bytes 74308.00 bytes/sec
total size is 865270 speedup is 23.29
As you can see, the output of the last command is truncated.
The problem is that the output is written in non-blocking mode, and
that when the write() returns EAGAIN, the output may be discarded.
The attached patch adds a check for EAGAIN, and retries the write()
after 20 msec, which fixes the problem.
--
Dick Streefland //// Altium Software BV
dick.streefland at altium.nl (@ @) http://www.altium.com
--------------------------------oOO--(_)--OOo---------------------------
-------------- next part --------------
--- rsync-2.5.5/log.c.orig Mon Feb 18 20:51:12 2002
+++ rsync-2.5.5/log.c Wed May 15 16:12:18 2002
@@ -116,7 +116,12 @@
int n = write(log_error_fd, el->buf+el->written, el->len - el->written);
/* don't check for an error if the best way of handling the error is
to ignore it */
- if (n == -1) break;
+ if (n == -1) {
+ if (errno == EAGAIN) {
+ msleep(20);
+ }
+ break;
+ }
if (n > 0) {
el->written += n;
}
More information about the rsync
mailing list