1 --- batch.c 15 May 2004 19:31:10 -0000 1.32
2 +++ batch.c 18 Jun 2004 17:16:35 -0000
3 @@ -172,6 +172,7 @@ void close_batch_csums_file(void)
6 * Write csum info to batch file
7 + * If flist_entry < 0, just open the file
9 * @todo This will break if s->count is ever larger than maxint. The
10 * batch code should probably be changed to consistently use the
11 @@ -198,6 +199,9 @@ void write_batch_csum_info(int *flist_en
15 + if (*flist_entry < 0)
18 write_batch_csums_file(flist_entry, sizeof (int));
19 int_count = s ? (int) s->count : 0;
20 write_batch_csums_file(&int_count, sizeof int_count);
21 @@ -285,6 +289,9 @@ void write_batch_delta_file(char *buff,
28 if (write(f_delta, buff, bytes_to_write) < 0) {
29 rsyserr(FERROR, errno, "Batch file %s write error", filename);
31 --- flist.c 18 Jun 2004 16:29:21 -0000 1.231
32 +++ flist.c 18 Jun 2004 17:16:35 -0000
33 @@ -950,7 +950,7 @@ void send_file_name(int f, struct file_l
38 + if (write_batch) /* TODO: why? remove and test. */
39 file->flags |= FLAG_TOP_DIR;
41 if (file->basename[0]) {
42 @@ -1308,6 +1308,18 @@ struct file_list *recv_file_list(int f)
44 io_error |= read_int(f);
47 + /* TODO: remove this FLAG_TOP_DIR stuff and test
48 + * CAS: I'm not sure what the FLAG_TOP_DIR does,
49 + * but we set it here, just so it matches what
50 + * happens for write_batch on the sender paths.
53 + for (i = 0; i < flist->count; i++)
54 + flist->files[i]->flags |= FLAG_TOP_DIR;
56 + write_batch_flist_info(flist->count, flist->files);
61 --- generator.c 18 Jun 2004 16:30:24 -0000 1.88
62 +++ generator.c 18 Jun 2004 17:16:35 -0000
63 @@ -48,6 +48,7 @@ extern int whole_file;
64 extern int local_server;
65 extern int read_batch;
66 extern int write_batch;
67 +extern int read_batch;
69 extern int only_existing;
70 extern int orig_umask;
71 @@ -227,16 +228,27 @@ static BOOL disable_deltas_p(void)
72 * Generate and send a stream of signatures/checksums that describe a buffer
74 * Generate approximately one checksum every block_len bytes.
76 + * The flist_idx arg is only for the purpose of being able to call
77 + * write_batch_csum_info(). Another (better?) way would be to instead
78 + * return a pointer to a sum_struct, and then call write_batch_csum_info()
81 -static void generate_and_send_sums(struct map_struct *buf, size_t len, int f_out)
82 +static void generate_and_send_sums(struct map_struct *buf, size_t len, int f_out,
87 struct sum_struct sum;
90 sum_sizes_sqroot(&sum, len);
92 write_sum_head(f_out, &sum);
93 + if (write_batch) { /* save all the sums to write out */
94 + sum.sums = new_array(struct sum_buf, sum.count);
96 + out_of_memory("generate_and_send_sums");
99 for (i = 0; i < sum.count; i++) {
100 unsigned int n1 = MIN(len, sum.blength);
101 @@ -256,10 +268,30 @@ static void generate_and_send_sums(struc
102 write_buf(f_out, sum2, sum.s2length);
106 + if (write_batch) { /* we're receiver */
107 + /* we only have to save the sums
108 + * if we want to write them out */
109 + sum.sums[i].sum1 = sum1;
110 + for (j = 0; j < SUM_LENGTH ; j++)
111 + sum.sums[i].sum2[j] = sum2[j];
115 + write_batch_csum_info(&flist_idx, &sum);
121 +void write_null_sum(int f_out, int i)
123 + write_int(f_out, i);
125 + write_sum_head(f_out, NULL);
127 + write_batch_csum_info(&i, NULL);
131 * Acts on file number @p i from @p flist, whose name is @p fname.
132 @@ -454,9 +486,7 @@ void recv_generator(char *fname, struct
133 if (preserve_hard_links && hard_link_check(file, HL_SKIP))
135 if (errno == ENOENT) {
136 - write_int(f_out,i);
138 - write_sum_head(f_out, NULL);
139 + write_null_sum(f_out, i);
140 } else if (verbose > 1) {
141 rsyserr(FERROR, errno,
142 "recv_generator: failed to open %s",
143 @@ -473,9 +503,7 @@ void recv_generator(char *fname, struct
144 /* now pretend the file didn't exist */
145 if (preserve_hard_links && hard_link_check(file, HL_SKIP))
147 - write_int(f_out,i);
149 - write_sum_head(f_out, NULL);
150 + write_null_sum(f_out, i);
154 @@ -503,8 +531,7 @@ void recv_generator(char *fname, struct
157 if (disable_deltas_p()) {
158 - write_int(f_out,i);
159 - write_sum_head(f_out, NULL);
160 + write_null_sum(f_out, i);
164 @@ -517,8 +544,7 @@ void recv_generator(char *fname, struct
165 /* pretend the file didn't exist */
166 if (preserve_hard_links && hard_link_check(file, HL_SKIP))
168 - write_int(f_out,i);
169 - write_sum_head(f_out, NULL);
170 + write_null_sum(f_out, i);
174 @@ -536,7 +562,7 @@ void recv_generator(char *fname, struct
175 rprintf(FINFO, "generating and sending sums for %d\n", i);
178 - generate_and_send_sums(mapbuf, st.st_size, f_out);
179 + generate_and_send_sums(mapbuf, st.st_size, f_out, i);
183 --- main.c 18 Jun 2004 16:50:20 -0000 1.198
184 +++ main.c 18 Jun 2004 17:16:36 -0000
185 @@ -1029,6 +1029,10 @@ int main(int argc,char *argv[])
187 if (write_batch && !am_server) {
188 write_batch_argvs_file(orig_argc, orig_argv);
189 + /* initialize static fds */
191 + write_batch_csum_info(&ret, NULL);
192 + write_batch_delta_file(NULL, 0);
195 if (am_daemon && !am_server)
196 --- options.c 7 Jun 2004 22:05:22 -0000 1.156
197 +++ options.c 18 Jun 2004 17:16:36 -0000
198 @@ -643,6 +643,15 @@ int parse_arguments(int *argc, const cha
199 "write-batch and read-batch can not be used together\n");
200 exit_cleanup(RERR_SYNTAX);
202 + if ((write_batch || read_batch) && am_server) {
204 + "batch-mode is incompatible with server mode\n");
207 + /* We don't actually exit_cleanup(), so that we can still
208 + * service older version clients that send batch args to
211 if (batch_prefix && strlen(batch_prefix) > MAX_BATCH_PREFIX_LEN) {
213 "the batch-file prefix must be %d characters or less.\n",
214 @@ -884,13 +893,6 @@ void server_options(char **args,int *arg
218 - if (batch_prefix) {
219 - char *r_or_w = write_batch ? "write" : "read";
220 - if (asprintf(&arg, "--%s-batch=%s", r_or_w, batch_prefix) < 0)
226 if (asprintf(&arg, "--timeout=%d", io_timeout) < 0)
228 --- pipe.c 18 Jun 2004 16:00:33 -0000 1.8
229 +++ pipe.c 18 Jun 2004 17:16:36 -0000
230 @@ -26,6 +26,7 @@ extern int am_server;
231 extern int blocking_io;
232 extern int orig_umask;
233 extern int read_batch;
234 +extern int write_batch;
235 extern int filesfrom_fd;
238 @@ -117,6 +118,13 @@ pid_t local_child(int argc, char **argv,
239 am_sender = read_batch ? 0 : !am_sender;
242 + /* There is write_batch code on both the receiver and
243 + * sender sides. In local_child, both are local processes,
244 + * so we must make sure that only one actually writes. It
245 + * shouldn't matter which one -- here we prevent the server
252 --- receiver.c 14 Jun 2004 15:09:36 -0000 1.82
253 +++ receiver.c 18 Jun 2004 17:16:36 -0000
254 @@ -46,6 +46,7 @@ extern int cleanup_got_literal;
255 extern int module_id;
256 extern int ignore_errors;
257 extern int orig_umask;
258 +extern int write_batch;
259 extern int keep_partial;
260 extern int checksum_seed;
262 @@ -279,6 +280,8 @@ static int receive_data(int f_in,struct
265 read_buf(f_in,file_sum2,MD4_SUM_LENGTH);
267 + write_batch_delta_file(file_sum2, MD4_SUM_LENGTH);
269 rprintf(FINFO,"got file_sum\n");
271 @@ -334,6 +337,9 @@ int recv_files(int f_in,struct file_list
276 + write_batch_delta_file((char *) &i, sizeof i);
278 if (i < 0 || i >= flist->count) {
279 rprintf(FERROR,"Invalid file index %d in recv_files (count=%d)\n",
281 --- token.c 18 Jun 2004 16:22:14 -0000 1.31
282 +++ token.c 18 Jun 2004 17:16:36 -0000
283 @@ -80,6 +80,8 @@ static int simple_recv_token(int f,char
288 + write_batch_delta_file((char *) &i, sizeof(int));
292 @@ -89,6 +91,8 @@ static int simple_recv_token(int f,char
293 n = MIN(CHUNK_SIZE,residue);
297 + write_batch_delta_file(buf, n);