extern int always_checksum;
extern time_t starttime;
+extern int remote_version;
+
extern char *backup_suffix;
extern int block_size;
generate approximately one checksum every n bytes
*/
-static struct sum_struct *generate_sums(char *buf,off_t len,int n)
+static struct sum_struct *generate_sums(struct map_struct *buf,off_t len,int n)
{
int i;
struct sum_struct *s;
{
int fd;
struct stat st;
- char *buf;
+ struct map_struct *buf;
struct sum_struct *s;
char sum[SUM_LENGTH];
int statret;
write_flush(f_out);
close(fd);
- unmap_file(buf,st.st_size);
+ unmap_file(buf);
free_sums(s);
}
-static void receive_data(int f_in,char *buf,int fd,char *fname)
+static void receive_data(int f_in,struct map_struct *buf,int fd,char *fname)
{
int i,n,remainder,len,count;
off_t offset = 0;
}
-int recv_files(int f_in,struct file_list *flist,char *local_name)
+int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
{
int fd1,fd2;
struct stat st;
char *fname;
char fnametmp[MAXPATHLEN];
- char *buf;
+ struct map_struct *buf;
int i;
struct file_struct *file;
+ int phase=0;
if (verbose > 2) {
fprintf(FERROR,"recv_files(%d) starting\n",flist->count);
while (1)
{
i = read_int(f_in);
- if (i == -1) break;
+ if (i == -1) {
+ if (phase==0 && remote_version >= 13) {
+ phase++;
+ write_int(f_gen,-1);
+ write_flush(f_gen);
+ continue;
+ }
+ break;
+ }
file = &flist->files[i];
fname = file->name;
receive_data(f_in,buf,fd2,fname);
if (fd1 != -1) {
- unmap_file(buf,st.st_size);
+ unmap_file(buf);
close(fd1);
}
close(fd2);
{
int fd;
struct sum_struct *s;
- char *buf;
+ struct map_struct *buf;
struct stat st;
char fname[MAXPATHLEN];
off_t total=0;
int i;
struct file_struct *file;
+ int phase = 0;
if (verbose > 2)
fprintf(FERROR,"send_files starting\n");
while (1)
{
i = read_int(f_in);
- if (i == -1) break;
+ if (i == -1) {
+ if (phase==0 && remote_version >= 13) {
+ phase++;
+ write_int(f_out,-1);
+ write_flush(f_out);
+ continue;
+ }
+ break;
+ }
file = &flist->files[i];
match_sums(f_out,s,buf,st.st_size);
write_flush(f_out);
- unmap_file(buf,st.st_size);
+ unmap_file(buf);
close(fd);
free_sums(s);
-void generate_files(int f,struct file_list *flist,char *local_name)
+void generate_files(int f,struct file_list *flist,char *local_name,int f_recv)
{
int i;
recv_generator(local_name?local_name:file->name,
flist,i,f);
}
+
write_int(f,-1);
write_flush(f);
+
+ if (remote_version >= 13) {
+ /* go to the full checksum if anything has failed so far */
+ csum_length = SUM_LENGTH;
+
+ for (i=read_int(f_recv); i != -1; i=read_int(f_recv)) {
+ struct file_struct *file = &flist->files[i];
+ recv_generator(local_name?local_name:file->name,
+ flist,i,f);
+ }
+
+ write_int(f,-1);
+ write_flush(f);
+ }
+
+
if (verbose > 2)
fprintf(FERROR,"generator wrote %d\n",write_total());
}