X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/c627d61324e9dcd5df833ee6236dd10415f5bac4..4fe159a81d1f0c39aaa7f05dbb33b36d231e7c80:/main.c diff --git a/main.c b/main.c index feda8118..0af90e58 100644 --- a/main.c +++ b/main.c @@ -43,6 +43,7 @@ int local_server=0; int ignore_times=0; int delete_mode=0; int one_file_system=0; +int remote_version=0; int am_server = 0; static int sender = 0; @@ -235,6 +236,8 @@ static char *get_local_name(struct file_list *flist,char *name) if (mkdir(name,0777) != 0) { fprintf(stderr,"mkdir %s : %s\n",name,strerror(errno)); exit(1); + } else { + fprintf(am_server?stderr:stdout,"created directory %s\n",name); } if (chdir(name) != 0) { @@ -579,14 +582,16 @@ int main(int argc,char *argv[]) verbose = MAX(verbose,1); if (am_server) { - int version = read_int(STDIN_FILENO); - if (version != PROTOCOL_VERSION) { + remote_version = read_int(STDIN_FILENO); + if (remote_version < MIN_PROTOCOL_VERSION) { fprintf(stderr,"protocol version mismatch %d %d\n", - version,PROTOCOL_VERSION); + remote_version,PROTOCOL_VERSION); exit(1); } write_int(STDOUT_FILENO,PROTOCOL_VERSION); write_flush(STDOUT_FILENO); + + setup_protocol(); if (sender) { recv_exclude_list(STDIN_FILENO); @@ -650,7 +655,8 @@ int main(int argc,char *argv[]) } signal(SIGCHLD,SIG_IGN); - signal(SIGINT,sig_int); + signal(SIGINT,SIGNAL_CAST sig_int); + signal(SIGPIPE,SIGNAL_CAST sig_int); if (!sender && argc != 1) { usage(stderr); @@ -662,13 +668,15 @@ int main(int argc,char *argv[]) write_int(f_out,PROTOCOL_VERSION); write_flush(f_out); { - int version = read_int(f_in); - if (version != PROTOCOL_VERSION) { + remote_version = read_int(f_in); + if (remote_version < MIN_PROTOCOL_VERSION) { fprintf(stderr,"protocol version mismatch\n"); exit(1); } } + setup_protocol(); + if (verbose > 3) fprintf(stderr,"parent=%d child=%d sender=%d recurse=%d\n", (int)getpid(),pid,sender,recurse);