X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/26f76b7912cbd004c707e6304abdc99830ad5680..22d49dc429f18b5cccf0f237dfd95cceb0b48367:/main.c diff --git a/main.c b/main.c index 87711c29..b40922a2 100644 --- a/main.c +++ b/main.c @@ -27,6 +27,7 @@ extern struct stats stats; extern int am_root; extern int am_server; extern int am_sender; +extern int am_generator; extern int am_daemon; extern int verbose; extern int blocking_io; @@ -57,6 +58,7 @@ extern char *rsync_path; extern char *shell_cmd; extern struct file_list *batch_flist; + /* there's probably never more than at most 2 outstanding child processes, * but set it higher just in case. */ @@ -198,7 +200,7 @@ static void show_malloc_stats(void) getpid(), am_server ? "server " : "", am_daemon ? "daemon " : "", - am_sender ? "sender" : "receiver"); + who_am_i()); rprintf(FINFO, " arena: %10d (bytes from sbrk)\n", mi.arena); rprintf(FINFO, " ordblks: %10d (chunks not in use)\n", mi.ordblks); rprintf(FINFO, " smblks: %10d\n", mi.smblks); @@ -305,8 +307,6 @@ oom: } - - static char *get_local_name(struct file_list *flist,char *name) { STRUCT_STAT st; @@ -321,7 +321,7 @@ static char *get_local_name(struct file_list *flist,char *name) if (do_stat(name,&st) == 0) { if (S_ISDIR(st.st_mode)) { - if (!push_dir(name, 0)) { + if (!push_dir(name)) { rprintf(FERROR, "push_dir %s failed: %s (1)\n", full_fname(name), strerror(errno)); exit_cleanup(RERR_FILESELECT); @@ -347,7 +347,7 @@ static char *get_local_name(struct file_list *flist,char *name) rprintf(FINFO,"created directory %s\n",name); } - if (!push_dir(name, 0)) { + if (!push_dir(name)) { rprintf(FERROR, "push_dir %s failed: %s (2)\n", full_fname(name), strerror(errno)); exit_cleanup(RERR_FILESELECT); @@ -363,10 +363,12 @@ static void do_server_sender(int f_in, int f_out, int argc,char *argv[]) struct file_list *flist; char *dir = argv[0]; - if (verbose > 2) - rprintf(FINFO,"server_sender starting pid=%d\n",(int)getpid()); + if (verbose > 2) { + rprintf(FINFO, "server_sender starting pid=%ld\n", + (long)getpid()); + } - if (!relative_paths && !push_dir(dir, 0)) { + if (!relative_paths && !push_dir(dir)) { rprintf(FERROR, "push_dir %s failed: %s (3)\n", full_fname(dir), strerror(errno)); exit_cleanup(RERR_FILESELECT); @@ -453,6 +455,8 @@ static int do_recv(int f_in,int f_out,struct file_list *flist,char *local_name) msleep(20); } + am_generator = 1; + close(error_pipe[1]); if (f_in != f_out) close(f_in); @@ -462,7 +466,7 @@ static int do_recv(int f_in,int f_out,struct file_list *flist,char *local_name) generate_files(f_out, flist, local_name); - get_redo_num(); /* Read final -1, and any prior messages. */ + get_redo_num(); /* Read final MSG_DONE and any prior messages. */ io_flush(FULL_FLUSH); if (protocol_version >= 24) { /* send a final goodbye message */ @@ -484,8 +488,10 @@ static void do_server_recv(int f_in, int f_out, int argc,char *argv[]) char *local_name=NULL; char *dir = NULL; - if (verbose > 2) - rprintf(FINFO,"server_recv(%d) starting pid=%d\n",argc,(int)getpid()); + if (verbose > 2) { + rprintf(FINFO, "server_recv(%d) starting pid=%ld\n", + argc, (long)getpid()); + } if (am_daemon && lp_read_only(module_id) && !am_sender) { rprintf(FERROR,"ERROR: module is read only\n"); @@ -498,7 +504,7 @@ static void do_server_recv(int f_in, int f_out, int argc,char *argv[]) dir = argv[0]; argc--; argv++; - if (!am_daemon && !push_dir(dir, 0)) { + if (!am_daemon && !push_dir(dir)) { rprintf(FERROR, "push_dir %s failed: %s (4)\n", full_fname(dir), strerror(errno)); exit_cleanup(RERR_FILESELECT); @@ -819,7 +825,7 @@ static int start_client(int argc, char *argv[]) } if (shell_machine) { - p = strchr(shell_machine,'@'); + p = strrchr(shell_machine,'@'); if (p) { *p = 0; shell_user = shell_machine; @@ -1005,7 +1011,7 @@ int main(int argc,char *argv[]) * (implemented by forking "pwd" and reading its output) doesn't * work when there are other child processes. Also, on all systems * that implement getcwd that way "pwd" can't be found after chroot. */ - push_dir(NULL,0); + push_dir(NULL); if (write_batch && !am_server) { write_batch_argvs_file(orig_argc, orig_argv);