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 --- orig/clientserver.c 2005-04-09 17:38:31
7 +++ clientserver.c 2005-05-16 01:02:41
8 @@ -40,8 +40,6 @@ extern int sanitize_paths;
9 extern int filesfrom_fd;
10 extern int remote_protocol;
11 extern int protocol_version;
12 -extern int io_timeout;
13 -extern int select_timeout;
14 extern int orig_umask;
16 extern int default_af_hint;
17 @@ -518,11 +516,8 @@ static int rsync_module(int f_in, int f_
18 exit_cleanup(RERR_UNSUPPORTED);
21 - if (lp_timeout(i)) {
22 - io_timeout = lp_timeout(i);
23 - if (io_timeout < select_timeout)
24 - select_timeout = io_timeout;
27 + set_io_timeout(lp_timeout(i));
29 start_server(f_in, f_out, argc, argp);
31 --- orig/generator.c 2005-05-14 19:51:15
32 +++ generator.c 2005-05-16 01:02:43
33 @@ -59,8 +59,8 @@ extern int csum_length;
34 extern int ignore_times;
36 extern OFF_T max_size;
37 -extern int io_timeout;
39 +extern int allowed_lull;
40 extern int sock_f_out;
41 extern int ignore_timeout;
42 extern int protocol_version;
43 @@ -89,8 +89,6 @@ extern int backup_suffix_len;
44 extern struct file_list *the_file_list;
45 extern struct filter_list_struct server_filter_list;
47 -int allowed_lull = 0;
49 static int deletion_count = 0; /* used to implement --max-delete */
52 @@ -1145,10 +1143,11 @@ notify_others:
54 void generate_files(int f_out, struct file_list *flist, char *local_name)
58 char fbuf[MAXPATHLEN];
59 int itemizing, maybe_PERMS_REPORT;
61 + int lull_mod = allowed_lull * 5;
62 int need_retouch_dir_times = preserve_times && !omit_dir_times;
63 int need_retouch_dir_perms = 0;
64 int save_only_existing = only_existing;
65 @@ -1156,9 +1155,6 @@ void generate_files(int f_out, struct fi
66 int save_do_progress = do_progress;
67 int save_make_backups = make_backups;
69 - allowed_lull = read_batch ? 0 : (io_timeout + 1) / 2;
70 - lull_mod = allowed_lull * 5;
72 if (protocol_version >= 29) {
74 maybe_PERMS_REPORT = log_format_has_i ? 0 : PERMS_REPORT;
75 --- orig/io.c 2005-05-12 17:42:08
76 +++ io.c 2005-05-16 01:02:43
79 extern size_t bwlimit_writemax;
81 -extern int io_timeout;
82 extern int allowed_lull;
86 extern int am_generator;
88 +extern int read_batch;
89 extern int csum_length;
90 extern int checksum_seed;
91 extern int protocol_version;
92 @@ -59,7 +59,6 @@ extern struct stats stats;
93 extern struct file_list *the_file_list;
95 const char phase_unknown[] = "unknown";
96 -int select_timeout = SELECT_TIMEOUT;
97 int ignore_timeout = 0;
99 int batch_gen_fd = -1;
100 @@ -103,6 +102,8 @@ static char *io_filesfrom_bp;
101 static char io_filesfrom_lastchar;
102 static int io_filesfrom_buflen;
103 static size_t contiguous_write_len = 0;
104 +static int io_timeout;
105 +static int select_timeout = SELECT_TIMEOUT;
107 static void read_loop(int fd, char *buf, size_t len);
109 @@ -190,6 +191,18 @@ void io_set_sock_fds(int f_in, int f_out
113 +void set_io_timeout(int secs)
117 + if (!io_timeout || io_timeout > SELECT_TIMEOUT)
118 + select_timeout = SELECT_TIMEOUT;
120 + select_timeout = io_timeout;
122 + allowed_lull = read_batch ? 0 : (io_timeout + 1) / 2;
125 /* Setup the fd used to receive MSG_* messages. Only needed during the
126 * early stages of being a local sender (up through the sending of the
127 * file list) or when we're the generator (to fetch the messages from
128 @@ -1077,7 +1090,7 @@ static void writefd_unbuffered(int fd,ch
129 /* If the other side is sending us error messages, try
130 * to grab any messages they sent before they died. */
131 while (fd == sock_f_out && io_multiplexing_in) {
132 - io_timeout = select_timeout = 30;
133 + set_io_timeout(30);
135 readfd_unbuffered(sock_f_in, io_filesfrom_buf,
136 sizeof io_filesfrom_buf);
137 --- orig/options.c 2005-05-10 15:32:58
138 +++ options.c 2005-05-16 01:02:43
141 extern int module_id;
142 extern int sanitize_paths;
143 -extern int select_timeout;
144 extern struct filter_list_struct filter_list;
145 extern struct filter_list_struct server_filter_list;
147 @@ -75,7 +74,7 @@ int relative_paths = -1;
148 int implied_dirs = 1;
150 int force_delete = 0;
152 +int allowed_lull = 0;
153 char *files_from = NULL;
154 int filesfrom_fd = -1;
155 char *filesfrom_host = NULL;
156 @@ -161,6 +160,7 @@ int list_only = 0;
157 char *batch_name = NULL;
159 static int daemon_opt; /* sets am_daemon after option error-reporting */
160 +static int timeout_val;
161 static int F_option_cnt = 0;
162 static int modify_window_set;
163 static int itemize_changes = 0;
164 @@ -363,8 +363,7 @@ void usage(enum logcode F)
165 enum {OPT_VERSION = 1000, OPT_DAEMON, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
166 OPT_FILTER, OPT_COMPARE_DEST, OPT_COPY_DEST, OPT_LINK_DEST,
167 OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_MODIFY_WINDOW,
168 - OPT_READ_BATCH, OPT_WRITE_BATCH, OPT_ONLY_WRITE_BATCH,
169 - OPT_TIMEOUT, OPT_MAX_SIZE,
170 + OPT_READ_BATCH, OPT_WRITE_BATCH, OPT_ONLY_WRITE_BATCH, OPT_MAX_SIZE,
171 OPT_REFUSED_BASE = 9000};
173 static struct poptOption long_options[] = {
174 @@ -428,7 +427,7 @@ static struct poptOption long_options[]
175 {"block-size", 'B', POPT_ARG_LONG, &block_size, 0, 0, 0 },
176 {"max-delete", 0, POPT_ARG_INT, &max_delete, 0, 0, 0 },
177 {"max-size", 0, POPT_ARG_STRING, &max_size_arg, OPT_MAX_SIZE, 0, 0 },
178 - {"timeout", 0, POPT_ARG_INT, &io_timeout, OPT_TIMEOUT, 0, 0 },
179 + {"timeout", 0, POPT_ARG_INT, &timeout_val, 0, 0, 0 },
180 {"temp-dir", 'T', POPT_ARG_STRING, &tmpdir, 0, 0, 0 },
181 {"compare-dest", 0, POPT_ARG_STRING, 0, OPT_COMPARE_DEST, 0, 0 },
182 {"copy-dest", 0, POPT_ARG_STRING, 0, OPT_COPY_DEST, 0, 0 },
183 @@ -844,11 +843,6 @@ int parse_arguments(int *argc, const cha
188 - if (io_timeout && io_timeout < select_timeout)
189 - select_timeout = io_timeout;
195 @@ -1115,6 +1109,8 @@ int parse_arguments(int *argc, const cha
199 + set_io_timeout(timeout_val);
201 if (verbose && !log_format) {
203 log_before_transfer = !am_server;
204 @@ -1357,8 +1353,8 @@ void server_options(char **args,int *arg
205 args[ac++] = max_size_arg;
209 - if (asprintf(&arg, "--timeout=%d", io_timeout) < 0)
211 + if (asprintf(&arg, "--timeout=%d", timeout_val) < 0)
215 --- orig/sender.c 2005-04-14 01:53:12
216 +++ sender.c 2005-05-16 01:02:44
217 @@ -28,6 +28,7 @@ extern int log_format_has_i;
218 extern int daemon_log_format_has_i;
219 extern int csum_length;
221 +extern int allowed_lull;
222 extern int protocol_version;
223 extern int remove_sent_files;
224 extern int updating_basis_file;
225 @@ -56,6 +57,7 @@ static struct sum_struct *receive_sums(i
227 struct sum_struct *s;
229 + int lull_mod = allowed_lull * 5;
232 if (!(s = new(struct sum_struct)))
233 @@ -89,6 +91,9 @@ static struct sum_struct *receive_sums(i
234 s->sums[i].len = s->blength;
235 offset += s->sums[i].len;
237 + if (allowed_lull && !(i % lull_mod))
238 + maybe_send_keepalive();
242 "chunk[%d] len=%d offset=%.0f sum1=%08x\n",