Matt McCutchen's Web Site
/
rsync
/
rsync.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Check the error return of flush_write_file().
[rsync/rsync.git]
/
receiver.c
diff --git
a/receiver.c
b/receiver.c
index
059f762
..
35f964e
100644
(file)
--- a/
receiver.c
+++ b/
receiver.c
@@
-214,7
+214,7
@@
static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
struct sum_struct sum;
unsigned int len;
OFF_T offset = 0;
struct sum_struct sum;
unsigned int len;
OFF_T offset = 0;
- OFF_T offset2
, seekto = 0
;
+ OFF_T offset2;
char *data;
int i;
char *map = NULL;
char *data;
int i;
char *map = NULL;
@@
-247,11
+247,8
@@
static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
sum_update(data,i);
sum_update(data,i);
- if (fd != -1 && write_file(fd,data,i) != i) {
- rsyserr(FERROR, errno, "write failed on %s",
- full_fname(fname));
- exit_cleanup(RERR_FILEIO);
- }
+ if (fd != -1 && write_file(fd,data,i) != i)
+ goto report_write_error;
offset += i;
continue;
}
offset += i;
continue;
}
@@
-276,26
+273,21
@@
static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
}
if (inplace) {
}
if (inplace) {
- if (offset == offset2) {
- seekto = offset += len;
- continue;
- }
- if (seekto && fd != -1) {
- flush_write_file(fd);
- if (do_lseek(fd, seekto, SEEK_SET) != seekto) {
+ if (offset == offset2 && fd != -1) {
+ if (flush_write_file(fd) < 0)
+ goto report_write_error;
+ offset += len;
+ if (do_lseek(fd, len, SEEK_CUR) != offset) {
rsyserr(FERROR, errno,
"lseek failed on %s",
full_fname(fname));
exit_cleanup(RERR_FILEIO);
}
rsyserr(FERROR, errno,
"lseek failed on %s",
full_fname(fname));
exit_cleanup(RERR_FILEIO);
}
-
seekto = 0
;
+
continue
;
}
}
}
}
- if (fd != -1 && write_file(fd, map, len) != (int)len) {
- rsyserr(FERROR, errno, "write failed on %s",
- full_fname(fname));
- exit_cleanup(RERR_FILEIO);
- }
+ if (fd != -1 && write_file(fd, map, len) != (int)len)
+ goto report_write_error;
offset += len;
}
offset += len;
}
@@
-310,6
+302,7
@@
static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
end_progress(total_size);
if (fd != -1 && offset > 0 && sparse_end(fd) != 0) {
end_progress(total_size);
if (fd != -1 && offset > 0 && sparse_end(fd) != 0) {
+ report_write_error:
rsyserr(FERROR, errno, "write failed on %s",
full_fname(fname));
exit_cleanup(RERR_FILEIO);
rsyserr(FERROR, errno, "write failed on %s",
full_fname(fname));
exit_cleanup(RERR_FILEIO);