#define CSUM_CHUNK 64
-static char *tmpchunk = NULL;
-
+int checksum_seed = 0;
/*
a simple 32 bit checksum that can be upadted from either end
{
int i;
MDstruct MD;
+ static char *buf1 = NULL;
+ static int len1 = 0;
+
+ if (len > len1) {
+ if (buf1) free(buf1);
+ buf1 = (char *)malloc(len+sizeof(checksum_seed));
+ len1 = len;
+ if (!buf1) out_of_memory("get_checksum2");
+ }
MDbegin(&MD);
- for(i = 0; i + CSUM_CHUNK <= len; i += CSUM_CHUNK) {
- bcopy(buf+i,tmpchunk,CSUM_CHUNK);
- MDupdate(&MD, tmpchunk, CSUM_CHUNK*8);
+ bcopy(buf,buf1,len);
+ if (checksum_seed) {
+ bcopy((char *)&checksum_seed,buf1+len,sizeof(checksum_seed));
+ len += sizeof(checksum_seed);
}
- bcopy(buf+i,tmpchunk,len-i);
- MDupdate(&MD, tmpchunk, (len-i)*8);
+ for(i = 0; i + CSUM_CHUNK <= len; i += CSUM_CHUNK) {
+ MDupdate(&MD, buf1+i, CSUM_CHUNK*8);
+ }
+ MDupdate(&MD, buf1+i, (len-i)*8);
sum_put(&MD,sum);
}
char *buf;
int fd;
int len = size;
+ char tmpchunk[CSUM_CHUNK];
bzero(sum,csum_length);
void checksum_init(void)
{
- tmpchunk = (char *)malloc(CSUM_CHUNK);
- if (!tmpchunk) out_of_memory("checksum_init");
}
#include "rsync.h"
+extern int am_server;
+
extern int csum_length;
extern int preserve_links;
extern int preserve_gid;
extern int preserve_times;
extern int always_checksum;
+extern int checksum_seed;
extern int remote_version;
-void setup_protocol(void)
+void setup_protocol(int f_out,int f_in)
{
+ if (am_server) {
+ remote_version = read_int(f_in);
+ write_int(f_out,PROTOCOL_VERSION);
+ write_flush(f_out);
+ } else {
+ write_int(f_out,PROTOCOL_VERSION);
+ write_flush(f_out);
+ remote_version = read_int(f_in);
+ }
+
+ if (remote_version < MIN_PROTOCOL_VERSION ||
+ remote_version > MAX_PROTOCOL_VERSION) {
+ fprintf(FERROR,"protocol version mismatch - is your shell clean?\n");
+ exit_cleanup(1);
+ }
+
if (remote_version == 10) {
send_file_entry = send_file_entry_v10;
receive_file_entry = receive_file_entry_v10;
send_file_entry = send_file_entry_v11;
receive_file_entry = receive_file_entry_v11;
}
+
+ if (remote_version >= 12) {
+ if (am_server) {
+ checksum_seed = time(NULL);
+ write_int(f_out,checksum_seed);
+ } else {
+ checksum_seed = read_int(f_in);
+ }
+ }
}
verbose = MAX(verbose,1);
if (am_server) {
- remote_version = read_int(STDIN_FILENO);
- if (remote_version < MIN_PROTOCOL_VERSION ||
- remote_version > MAX_PROTOCOL_VERSION) {
- fprintf(FERROR,"protocol version mismatch - is your shell clean?\n");
- exit_cleanup(1);
- }
- write_int(STDOUT_FILENO,PROTOCOL_VERSION);
- write_flush(STDOUT_FILENO);
-
- setup_protocol();
+ setup_protocol(STDOUT_FILENO,STDIN_FILENO);
if (sender) {
recv_exclude_list(STDIN_FILENO);
pid = do_cmd(shell_cmd,shell_machine,shell_user,shell_path,&f_in,&f_out);
- write_int(f_out,PROTOCOL_VERSION);
- write_flush(f_out);
- {
- remote_version = read_int(f_in);
- if (remote_version < MIN_PROTOCOL_VERSION ||
- remote_version > MAX_PROTOCOL_VERSION) {
- fprintf(FERROR,"protocol version mismatch - is your shell clean?\n");
- exit_cleanup(1);
- }
- }
-
- setup_protocol();
+ setup_protocol(f_out,f_in);
if (verbose > 3)
fprintf(FERROR,"parent=%d child=%d sender=%d recurse=%d\n",
#define SAME_TIME (1<<7)
/* update this if you make incompatible changes */
-#define PROTOCOL_VERSION 11
+#define PROTOCOL_VERSION 12
#define MIN_PROTOCOL_VERSION 10
#define MAX_PROTOCOL_VERSION 20