/*
- send a header that says "we have no checksums" down the f_out fd
+ * NULL sum_struct means we have no checksums
*/
-static void send_null_sums(int f_out)
+
+void write_sum_head(int f, struct sum_struct *sum)
{
- write_int(f_out, 0);
- write_int(f_out, block_size);
- write_int(f_out, 0);
+ static struct sum_struct null_sum;
+
+ if (sum == (struct sum_struct *)NULL)
+ sum = &null_sum;
+
+ write_int(f, sum->count);
+ write_int(f, sum->blength);
+ if (remote_version >= 27)
+ write_int(f, sum->s2length);
+ write_int(f, sum->remainder);
}
sum.count = (len + (block_len - 1)) / block_len;
sum.remainder = (len % block_len);
- sum.n = block_len;
+ sum.blength = block_len;
sum.flength = len;
+ sum.s2length = csum_length;
/* not needed here sum.sums = NULL; */
if (sum.count && verbose > 3) {
rprintf(FINFO, "count=%ld rem=%ld n=%ld flength=%.0f\n",
(long) sum.count, (long) sum.remainder,
- (long) sum.n, (double) sum.flength);
+ (long) sum.blength, (double) sum.flength);
}
- write_int(f_out, sum.count);
- write_int(f_out, sum.n);
- write_int(f_out, sum.remainder);
+ write_sum_head(f_out, &sum);
for (i = 0; i < sum.count; i++) {
int n1 = MIN(len, block_len);
i, (double) offset, n1, (unsigned long) sum1);
}
write_int(f_out, sum1);
- write_buf(f_out, sum2, csum_length);
+ write_buf(f_out, sum2, sum.s2length);
len -= n1;
offset += n1;
}
if (statret == -1) {
if (errno == ENOENT) {
write_int(f_out,i);
- if (!dry_run) send_null_sums(f_out);
+ if (!dry_run) write_sum_head(f_out, NULL);
} else {
if (verbose > 1)
rprintf(FERROR, RSYNC_NAME
/* now pretend the file didn't exist */
write_int(f_out,i);
- if (!dry_run) send_null_sums(f_out);
+ if (!dry_run) write_sum_head(f_out, NULL);
return;
}
if (disable_deltas_p()) {
write_int(f_out,i);
- send_null_sums(f_out);
+ write_sum_head(f_out, NULL);
return;
}
rprintf(FERROR,RSYNC_NAME": failed to open \"%s\", continuing : %s\n",fnamecmp,strerror(errno));
/* pretend the file didn't exist */
write_int(f_out,i);
- send_null_sums(f_out);
+ write_sum_head(f_out, NULL);
return;
}
write_int(f,-1);
- if (remote_version >= 13) {
- /* in newer versions of the protocol the files can cycle through
- the system more than once to catch initial checksum errors */
- for (i=read_int(f_recv); i != -1; i=read_int(f_recv)) {
- struct file_struct *file = flist->files[i];
- recv_generator(local_name?local_name:f_name(file),
- flist,i,f);
- }
+ /* files can cycle through the system more than once
+ * to catch initial checksum errors */
+ for (i=read_int(f_recv); i != -1; i=read_int(f_recv)) {
+ struct file_struct *file = flist->files[i];
+ recv_generator(local_name?local_name:f_name(file), flist,i,f);
+ }
- phase++;
- if (verbose > 2)
- rprintf(FINFO,"generate_files phase=%d\n",phase);
+ phase++;
+ if (verbose > 2)
+ rprintf(FINFO,"generate_files phase=%d\n",phase);
- write_int(f,-1);
- }
+ write_int(f,-1);
}