help me understand keepalive..

Wayne Davison wayned at samba.org
Sat May 14 19:50:40 GMT 2005


On Sat, May 14, 2005 at 12:28:20PM -0700, Wayne Davison wrote:
> I'll attach a patch that you can try out with 2.6.5pre1 or the
> latest "nightly" tar file (or probably even 2.6.4 [...]

I was a little hasty with that patch -- the sender needs to use the
global allowed_lull var, otherwise maybe_send_keepalive() sends too
many keep-alive packets.  Here's a better patch to try.

..wayne..
-------------- next part --------------
--- generator.c	13 May 2005 23:00:20 -0000	1.210
+++ generator.c	14 May 2005 19:41:57 -0000
@@ -59,8 +59,9 @@ extern int csum_length;
 extern int ignore_times;
 extern int size_only;
 extern OFF_T max_size;
-extern int io_timeout;
 extern int io_error;
+extern int io_timeout;
+extern int allowed_lull;
 extern int sock_f_out;
 extern int ignore_timeout;
 extern int protocol_version;
@@ -89,8 +90,6 @@ extern int backup_suffix_len;
 extern struct file_list *the_file_list;
 extern struct filter_list_struct server_filter_list;
 
-int allowed_lull = 0;
-
 static int deletion_count = 0; /* used to implement --max-delete */
 
 
@@ -1145,10 +1144,11 @@ notify_others:
 
 void generate_files(int f_out, struct file_list *flist, char *local_name)
 {
-	int i, lull_mod;
+	int i;
 	char fbuf[MAXPATHLEN];
 	int itemizing, maybe_PERMS_REPORT;
 	enum logcode code;
+	int lull_mod = allowed_lull * 5;
 	int need_retouch_dir_times = preserve_times && !omit_dir_times;
 	int need_retouch_dir_perms = 0;
 	int save_only_existing = only_existing;
@@ -1156,9 +1156,6 @@ void generate_files(int f_out, struct fi
 	int save_do_progress = do_progress;
 	int save_make_backups = make_backups;
 
-	allowed_lull = read_batch ? 0 : (io_timeout + 1) / 2;
-	lull_mod = allowed_lull * 5;
-
 	if (protocol_version >= 29) {
 		itemizing = 1;
 		maybe_PERMS_REPORT = log_format_has_i ? 0 : PERMS_REPORT;
--- options.c	9 May 2005 15:39:24 -0000	1.264
+++ options.c	14 May 2005 19:41:57 -0000
@@ -76,6 +76,7 @@ int implied_dirs = 1;
 int numeric_ids = 0;
 int force_delete = 0;
 int io_timeout = 0;
+int allowed_lull = 0;
 char *files_from = NULL;
 int filesfrom_fd = -1;
 char *filesfrom_host = NULL;
@@ -1115,6 +1116,8 @@ int parse_arguments(int *argc, const cha
 	if (dry_run)
 		do_xfers = 0;
 
+	allowed_lull = read_batch ? 0 : (io_timeout + 1) / 2;
+
 	if (verbose && !log_format) {
 		log_format = "%n%L";
 		log_before_transfer = !am_server;
--- sender.c	14 Apr 2005 01:45:47 -0000	1.88
+++ sender.c	14 May 2005 19:41:57 -0000
@@ -28,6 +28,8 @@ extern int log_format_has_i;
 extern int daemon_log_format_has_i;
 extern int csum_length;
 extern int io_error;
+extern int io_timeout;
+extern int allowed_lull;
 extern int protocol_version;
 extern int remove_sent_files;
 extern int updating_basis_file;
@@ -56,6 +58,7 @@ static struct sum_struct *receive_sums(i
 {
 	struct sum_struct *s;
 	int32 i;
+	int lull_mod = allowed_lull * 5;
 	OFF_T offset = 0;
 
 	if (!(s = new(struct sum_struct)))
@@ -89,6 +92,9 @@ static struct sum_struct *receive_sums(i
 			s->sums[i].len = s->blength;
 		offset += s->sums[i].len;
 
+		if (allowed_lull && !(i % lull_mod))
+			maybe_send_keepalive();
+
 		if (verbose > 3) {
 			rprintf(FINFO,
 				"chunk[%d] len=%d offset=%.0f sum1=%08x\n",


More information about the rsync mailing list