help me understand keepalive..

Wayne Davison wayned at samba.org
Sat May 14 19:28:20 GMT 2005


On Sat, May 14, 2005 at 12:08:44PM -0700, Wayne Davison wrote:
> So, it would be good to extend the keep-alive code to have the sender
> periodically spit out keep-alive packets to the receiver while it is
> busy reading the checksum data from the generator.

This turns out to be very easy -- I tested the result, and it appears
to work just great.  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,
though I didn't look to be 100% sure).

..wayne..
-------------- next part --------------
--- sender.c	14 Apr 2005 01:45:47 -0000	1.88
+++ sender.c	14 May 2005 19:21:02 -0000
@@ -28,6 +28,7 @@ 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 protocol_version;
 extern int remove_sent_files;
 extern int updating_basis_file;
@@ -56,6 +57,8 @@ static struct sum_struct *receive_sums(i
 {
 	struct sum_struct *s;
 	int32 i;
+	int allowed_lull = (io_timeout + 1) / 2;
+	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