Support new --append option.
[rsync/rsync.git] / sender.c
index a738b42..b19ecb5 100644 (file)
--- a/sender.c
+++ b/sender.c
@@ -27,7 +27,9 @@ extern int log_before_transfer;
 extern int log_format_has_i;
 extern int daemon_log_format_has_i;
 extern int csum_length;
+extern int append_mode;
 extern int io_error;
+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(int f)
 {
        struct sum_struct *s;
        int32 i;
+       int lull_mod = allowed_lull * 5;
        OFF_T offset = 0;
 
        if (!(s = new(struct sum_struct)))
@@ -70,6 +73,13 @@ static struct sum_struct *receive_sums(int f)
                        (double)s->count, (long)s->blength, (long)s->remainder);
        }
 
+       if (append_mode) {
+               s->flength = (OFF_T)s->count * s->blength;
+               if (s->remainder)
+                       s->flength -= s->blength - s->remainder;
+               return s;
+       }
+
        if (s->count == 0)
                return(s);
 
@@ -89,6 +99,9 @@ static struct sum_struct *receive_sums(int f)
                        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",
@@ -226,6 +239,7 @@ void send_files(struct file_list *flist, int f_out, int f_in)
                        /* For inplace: redo phase turns off the backup
                         * flag so that we do a regular inplace send. */
                        make_backups = 0;
+                       append_mode = 0;
                        continue;
                }