1 This patch extends the current keep-alive code (which currently only
2 handles silences in the generator's output) to deal with potential
3 silences in the sender's output when it is reading a lot of checksum
4 data from the generator (caused by the transfer of a large file).
6 After applying this patch, run "make proto".
8 --- orig/clientserver.c 2005-04-09 17:38:31
9 +++ clientserver.c 2005-05-16 01:02:41
10 @@ -40,8 +40,6 @@ extern int sanitize_paths;
11 extern int filesfrom_fd;
12 extern int remote_protocol;
13 extern int protocol_version;
14 -extern int io_timeout;
15 -extern int select_timeout;
16 extern int orig_umask;
18 extern int default_af_hint;
19 @@ -518,11 +516,8 @@ static int rsync_module(int f_in, int f_
20 exit_cleanup(RERR_UNSUPPORTED);
23 - if (lp_timeout(i)) {
24 - io_timeout = lp_timeout(i);
25 - if (io_timeout < select_timeout)
26 - select_timeout = io_timeout;
29 + set_io_timeout(lp_timeout(i));
31 start_server(f_in, f_out, argc, argp);
33 --- orig/generator.c 2005-05-14 19:51:15
34 +++ generator.c 2005-05-16 01:02:43
35 @@ -59,8 +59,8 @@ extern int csum_length;
36 extern int ignore_times;
38 extern OFF_T max_size;
39 -extern int io_timeout;
41 +extern int allowed_lull;
42 extern int sock_f_out;
43 extern int ignore_timeout;
44 extern int protocol_version;
45 @@ -89,8 +89,6 @@ extern int backup_suffix_len;
46 extern struct file_list *the_file_list;
47 extern struct filter_list_struct server_filter_list;
49 -int allowed_lull = 0;
51 static int deletion_count = 0; /* used to implement --max-delete */
54 @@ -1145,10 +1143,11 @@ notify_others:
56 void generate_files(int f_out, struct file_list *flist, char *local_name)
60 char fbuf[MAXPATHLEN];
61 int itemizing, maybe_PERMS_REPORT;
63 + int lull_mod = allowed_lull * 5;
64 int need_retouch_dir_times = preserve_times && !omit_dir_times;
65 int need_retouch_dir_perms = 0;
66 int save_only_existing = only_existing;
67 @@ -1156,9 +1155,6 @@ void generate_files(int f_out, struct fi
68 int save_do_progress = do_progress;
69 int save_make_backups = make_backups;
71 - allowed_lull = read_batch ? 0 : (io_timeout + 1) / 2;
72 - lull_mod = allowed_lull * 5;
74 if (protocol_version >= 29) {
76 maybe_PERMS_REPORT = log_format_has_i ? 0 : PERMS_REPORT;
77 --- orig/io.c 2005-05-12 17:42:08
78 +++ io.c 2005-05-16 01:02:43
81 extern size_t bwlimit_writemax;
83 -extern int io_timeout;
84 extern int allowed_lull;
88 extern int am_generator;
90 +extern int read_batch;
91 extern int csum_length;
92 extern int checksum_seed;
93 extern int protocol_version;
94 @@ -59,7 +59,6 @@ extern struct stats stats;
95 extern struct file_list *the_file_list;
97 const char phase_unknown[] = "unknown";
98 -int select_timeout = SELECT_TIMEOUT;
99 int ignore_timeout = 0;
101 int batch_gen_fd = -1;
102 @@ -103,6 +102,8 @@ static char *io_filesfrom_bp;
103 static char io_filesfrom_lastchar;
104 static int io_filesfrom_buflen;
105 static size_t contiguous_write_len = 0;
106 +static int io_timeout;
107 +static int select_timeout = SELECT_TIMEOUT;
109 static void read_loop(int fd, char *buf, size_t len);
111 @@ -190,6 +191,18 @@ void io_set_sock_fds(int f_in, int f_out
115 +void set_io_timeout(int secs)
119 + if (!io_timeout || io_timeout > SELECT_TIMEOUT)
120 + select_timeout = SELECT_TIMEOUT;
122 + select_timeout = io_timeout;
124 + allowed_lull = read_batch ? 0 : (io_timeout + 1) / 2;
127 /* Setup the fd used to receive MSG_* messages. Only needed during the
128 * early stages of being a local sender (up through the sending of the
129 * file list) or when we're the generator (to fetch the messages from
130 @@ -1077,7 +1090,7 @@ static void writefd_unbuffered(int fd,ch
131 /* If the other side is sending us error messages, try
132 * to grab any messages they sent before they died. */
133 while (fd == sock_f_out && io_multiplexing_in) {
134 - io_timeout = select_timeout = 30;
135 + set_io_timeout(30);
137 readfd_unbuffered(sock_f_in, io_filesfrom_buf,
138 sizeof io_filesfrom_buf);
139 --- orig/options.c 2005-05-10 15:32:58
140 +++ options.c 2005-05-16 01:02:43
143 extern int module_id;
144 extern int sanitize_paths;
145 -extern int select_timeout;
146 extern struct filter_list_struct filter_list;
147 extern struct filter_list_struct server_filter_list;
149 @@ -75,7 +74,7 @@ int relative_paths = -1;
150 int implied_dirs = 1;
152 int force_delete = 0;
154 +int allowed_lull = 0;
155 char *files_from = NULL;
156 int filesfrom_fd = -1;
157 char *filesfrom_host = NULL;
158 @@ -161,6 +160,7 @@ int list_only = 0;
159 char *batch_name = NULL;
161 static int daemon_opt; /* sets am_daemon after option error-reporting */
162 +static int timeout_val;
163 static int F_option_cnt = 0;
164 static int modify_window_set;
165 static int itemize_changes = 0;
166 @@ -363,8 +363,7 @@ void usage(enum logcode F)
167 enum {OPT_VERSION = 1000, OPT_DAEMON, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
168 OPT_FILTER, OPT_COMPARE_DEST, OPT_COPY_DEST, OPT_LINK_DEST,
169 OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_MODIFY_WINDOW,
170 - OPT_READ_BATCH, OPT_WRITE_BATCH, OPT_ONLY_WRITE_BATCH,
171 - OPT_TIMEOUT, OPT_MAX_SIZE,
172 + OPT_READ_BATCH, OPT_WRITE_BATCH, OPT_ONLY_WRITE_BATCH, OPT_MAX_SIZE,
173 OPT_REFUSED_BASE = 9000};
175 static struct poptOption long_options[] = {
176 @@ -428,7 +427,7 @@ static struct poptOption long_options[]
177 {"block-size", 'B', POPT_ARG_LONG, &block_size, 0, 0, 0 },
178 {"max-delete", 0, POPT_ARG_INT, &max_delete, 0, 0, 0 },
179 {"max-size", 0, POPT_ARG_STRING, &max_size_arg, OPT_MAX_SIZE, 0, 0 },
180 - {"timeout", 0, POPT_ARG_INT, &io_timeout, OPT_TIMEOUT, 0, 0 },
181 + {"timeout", 0, POPT_ARG_INT, &timeout_val, 0, 0, 0 },
182 {"temp-dir", 'T', POPT_ARG_STRING, &tmpdir, 0, 0, 0 },
183 {"compare-dest", 0, POPT_ARG_STRING, 0, OPT_COMPARE_DEST, 0, 0 },
184 {"copy-dest", 0, POPT_ARG_STRING, 0, OPT_COPY_DEST, 0, 0 },
185 @@ -844,11 +843,6 @@ int parse_arguments(int *argc, const cha
190 - if (io_timeout && io_timeout < select_timeout)
191 - select_timeout = io_timeout;
197 @@ -1115,6 +1109,8 @@ int parse_arguments(int *argc, const cha
201 + set_io_timeout(timeout_val);
203 if (verbose && !log_format) {
205 log_before_transfer = !am_server;
206 @@ -1357,8 +1353,8 @@ void server_options(char **args,int *arg
207 args[ac++] = max_size_arg;
211 - if (asprintf(&arg, "--timeout=%d", io_timeout) < 0)
213 + if (asprintf(&arg, "--timeout=%d", timeout_val) < 0)
217 --- orig/sender.c 2005-04-14 01:53:12
218 +++ sender.c 2005-05-16 01:02:44
219 @@ -28,6 +28,7 @@ extern int log_format_has_i;
220 extern int daemon_log_format_has_i;
221 extern int csum_length;
223 +extern int allowed_lull;
224 extern int protocol_version;
225 extern int remove_sent_files;
226 extern int updating_basis_file;
227 @@ -56,6 +57,7 @@ static struct sum_struct *receive_sums(i
229 struct sum_struct *s;
231 + int lull_mod = allowed_lull * 5;
234 if (!(s = new(struct sum_struct)))
235 @@ -89,6 +91,9 @@ static struct sum_struct *receive_sums(i
236 s->sums[i].len = s->blength;
237 offset += s->sums[i].len;
239 + if (allowed_lull && !(i % lull_mod))
240 + maybe_send_keepalive();
244 "chunk[%d] len=%d offset=%.0f sum1=%08x\n",