- Updated sysacls.c to latest samba version.
[rsync/rsync-patches.git] / keepalive.diff
CommitLineData
db730247
WD
1This patch extends the current keep-alive code (which currently only
2handles silences in the generator's output) to deal with potential
3silences in the sender's output when it is reading a lot of checksum
4data from the generator (caused by the transfer of a large file).
5
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;
15 extern int no_detach;
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);
19 }
20
21- if (lp_timeout(i)) {
22- io_timeout = lp_timeout(i);
23- if (io_timeout < select_timeout)
24- select_timeout = io_timeout;
25- }
26+ if (lp_timeout(i))
27+ set_io_timeout(lp_timeout(i));
28
29 start_server(f_in, f_out, argc, argp);
30
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;
35 extern int size_only;
36 extern OFF_T max_size;
37-extern int io_timeout;
38 extern int io_error;
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;
46
47-int allowed_lull = 0;
48-
49 static int deletion_count = 0; /* used to implement --max-delete */
50
51
52@@ -1145,10 +1143,11 @@ notify_others:
53
54 void generate_files(int f_out, struct file_list *flist, char *local_name)
55 {
56- int i, lull_mod;
57+ int i;
58 char fbuf[MAXPATHLEN];
59 int itemizing, maybe_PERMS_REPORT;
60 enum logcode code;
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;
68
69- allowed_lull = read_batch ? 0 : (io_timeout + 1) / 2;
70- lull_mod = allowed_lull * 5;
71-
72 if (protocol_version >= 29) {
73 itemizing = 1;
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
77@@ -42,13 +42,13 @@
78 extern int bwlimit;
79 extern size_t bwlimit_writemax;
80 extern int verbose;
81-extern int io_timeout;
82 extern int allowed_lull;
83 extern int am_server;
84 extern int am_daemon;
85 extern int am_sender;
86 extern int am_generator;
87 extern int eol_nulls;
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;
94
95 const char phase_unknown[] = "unknown";
96-int select_timeout = SELECT_TIMEOUT;
97 int ignore_timeout = 0;
98 int batch_fd = -1;
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;
106
107 static void read_loop(int fd, char *buf, size_t len);
108
109@@ -190,6 +191,18 @@ void io_set_sock_fds(int f_in, int f_out
110 sock_f_out = f_out;
111 }
112
113+void set_io_timeout(int secs)
114+{
115+ io_timeout = secs;
116+
117+ if (!io_timeout || io_timeout > SELECT_TIMEOUT)
118+ select_timeout = SELECT_TIMEOUT;
119+ else
120+ select_timeout = io_timeout;
121+
122+ allowed_lull = read_batch ? 0 : (io_timeout + 1) / 2;
123+}
124+
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);
134 ignore_timeout = 0;
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
139@@ -23,7 +23,6 @@
140
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;
146
147@@ -75,7 +74,7 @@ int relative_paths = -1;
148 int implied_dirs = 1;
149 int numeric_ids = 0;
150 int force_delete = 0;
151-int io_timeout = 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;
158
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};
172
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
184 }
185 break;
186
187- case OPT_TIMEOUT:
188- if (io_timeout && io_timeout < select_timeout)
189- select_timeout = io_timeout;
190- break;
191-
192 case OPT_LINK_DEST:
193 #ifdef HAVE_LINK
194 link_dest = 1;
195@@ -1115,6 +1109,8 @@ int parse_arguments(int *argc, const cha
196 if (dry_run)
197 do_xfers = 0;
198
199+ set_io_timeout(timeout_val);
200+
201 if (verbose && !log_format) {
202 log_format = "%n%L";
203 log_before_transfer = !am_server;
204@@ -1357,8 +1353,8 @@ void server_options(char **args,int *arg
205 args[ac++] = max_size_arg;
206 }
207
208- if (io_timeout) {
209- if (asprintf(&arg, "--timeout=%d", io_timeout) < 0)
210+ if (timeout_val) {
211+ if (asprintf(&arg, "--timeout=%d", timeout_val) < 0)
212 goto oom;
213 args[ac++] = arg;
214 }
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;
220 extern int io_error;
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
226 {
227 struct sum_struct *s;
228 int32 i;
229+ int lull_mod = allowed_lull * 5;
230 OFF_T offset = 0;
231
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;
236
237+ if (allowed_lull && !(i % lull_mod))
238+ maybe_send_keepalive();
239+
240 if (verbose > 3) {
241 rprintf(FINFO,
242 "chunk[%d] len=%d offset=%.0f sum1=%08x\n",