if (f == -1 || !am_sender) return;
}
- if (!verbose) return;
-
- if (am_server && !am_sender) return;
-
- if (am_server && am_sender) {
- write_longint(f,stats.total_read);
- write_longint(f,stats.total_written);
- write_longint(f,stats.total_size);
+ if (am_server) {
+ if (verbose && am_sender) {
+ write_longint(f,stats.total_read);
+ write_longint(f,stats.total_written);
+ write_longint(f,stats.total_size);
+ }
return;
}
-
- if (!am_sender) {
- int64 r;
+
+ /* this is the client */
+
+ if (!am_sender && verbose) {
+ /* note that if (!verbose && do_stats) then these values will
+ be taken from the receiver side's copy. The total size
+ is identical but the bytes read and written are slightly
+ different. It's done this way to avoid modifying the
+ protocol to support --stats without -v. */
stats.total_written = read_longint(f);
- r = read_longint(f);
+ stats.total_read = read_longint(f);
stats.total_size = read_longint(f);
- stats.total_read = r;
+
+ /* when the total_read was set above just now it would not
+ have included the last two longints, but the last
+ read_longint would have compensated for one of them.
+ Compensate for the other one too by adding 8. */
+ stats.total_read += sizeof(int64);
}
if (do_stats) {
(double)stats.total_read);
}
- rprintf(FINFO,"wrote %.0f bytes read %.0f bytes %.2f bytes/sec\n",
- (double)stats.total_written,
- (double)stats.total_read,
- (stats.total_written+stats.total_read)/(0.5 + (t-starttime)));
- rprintf(FINFO,"total size is %.0f speedup is %.2f\n",
- (double)stats.total_size,
- (1.0*stats.total_size)/(stats.total_written+stats.total_read));
+ if (verbose || do_stats) {
+ rprintf(FINFO,"wrote %.0f bytes read %.0f bytes %.2f bytes/sec\n",
+ (double)stats.total_written,
+ (double)stats.total_read,
+ (stats.total_written+stats.total_read)/(0.5 + (t-starttime)));
+ rprintf(FINFO,"total size is %.0f speedup is %.2f\n",
+ (double)stats.total_size,
+ (1.0*stats.total_size)/(stats.total_written+stats.total_read));
+ }
fflush(stdout);
fflush(stderr);
if (verbose > 2)
rprintf(FINFO,"get_local_name count=%d %s\n",
- flist->count, name);
+ flist->count, NS(name));
+
+ if (!name)
+ return NULL;
if (do_stat(name,&st) == 0) {
if (S_ISDIR(st.st_mode)) {
if (flist->count == 1)
return name;
- if (!name)
- return NULL;
-
if (do_mkdir(name,0777 & ~orig_umask) != 0) {
rprintf(FERROR,"mkdir %s : %s (1)\n",name,strerror(errno));
exit_cleanup(RERR_FILEIO);
carried across */
orig_umask = (int)umask(0);
- if (!parse_arguments(argc, argv)) {
+ if (!parse_arguments(argc, argv, 1)) {
exit_cleanup(RERR_SYNTAX);
}
signal(SIGHUP,SIGNAL_CAST sig_int);
signal(SIGTERM,SIGNAL_CAST sig_int);
+ /* Initialize push_dir here because on some old systems getcwd
+ (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);
+
if (am_daemon) {
return daemon_main();
}