Files
2016-10-31 17:09:01 -04:00

586 lines
17 KiB
Diff

diff -uNr rsync/flist.c rsync-3.1.2/flist.c
--- rsync/flist.c 2016-09-17 00:14:38.448855376 -0400
+++ rsync-3.1.2/flist.c 2015-08-08 15:47:03.000000000 -0400
@@ -2431,7 +2431,7 @@
if (DEBUG_GTE(FLIST, 3))
rprintf(FINFO, "[%s] flist_eof=1\n", who_am_i());
}
- //printf("how long build flist takes %ld\n", stats.flist_buildtime); // HPZ: I should not add this trace code, TODO: Delete
+
return flist;
}
diff -uNr rsync/main.c rsync-3.1.2/main.c
--- rsync/main.c 2016-10-07 15:10:04.094266860 -0400
+++ rsync-3.1.2/main.c 2015-08-24 00:58:18.000000000 -0400
@@ -23,12 +23,10 @@
#include "rsync.h"
#include "inums.h"
#include "io.h"
-#include <time.h> //HPZ:
#if defined CONFIG_LOCALE && defined HAVE_LOCALE_H
#include <locale.h>
#endif
-
extern int dry_run;
extern int list_only;
extern int io_timeout;
@@ -106,8 +104,6 @@
mode_t orig_umask = 0;
int batch_gen_fd = -1;
int sender_keeps_checksum = 0;
-struct timeval tv, td; // HPZ: only solution
-
/* There's probably never more than at most 2 outstanding child processes,
* but set it higher, just in case. */
@@ -353,7 +349,7 @@
write_batch < 0 ? " (BATCH ONLY)" : dry_run ? " (DRY RUN)" : "");
}
- fflush(stdout);
+ fflush(stdout);
fflush(stderr);
}
@@ -527,12 +523,11 @@
batch_gen_fd = from_gen_pipe[0];
*f_out_p = from_gen_pipe[1];
*f_in_p = batch_fd;
- //printf("1***\n");
pid = (pid_t)-1; /* no child pid */
#ifdef ICONV_CONST
setup_iconv();
#endif
- } else if (local_server) { // HPZ: Local Branch
+ } else if (local_server) {
/* If the user didn't request --[no-]whole-file, force
* it on, but only if we're not batch processing. */
if (whole_file < 0 && !write_batch)
@@ -543,7 +538,7 @@
setup_iconv();
#endif
} else {
- pid = piped_child(args, f_in_p, f_out_p); // HPZ: Remote Branch
+ pid = piped_child(args, f_in_p, f_out_p);
#ifdef ICONV_CONST
setup_iconv();
#endif
@@ -1112,9 +1107,9 @@
/* This is called once the connection has been negotiated. It is used
* for rsyncd, remote-shell, and local connections. */
-int client_run(int f_in, int f_out, pid_t pid, int argc, char *argv[])
+int client_run(int f_in, int f_out, pid_t pid, int argc, char *argv[])
{
- struct file_list *flist = NULL;
+ struct file_list *flist = NULL;
int exit_code = 0, exit_code2 = 0;
char *local_name = NULL;
@@ -1156,55 +1151,18 @@
send_filter_list(f_out);
if (filesfrom_host)
filesfrom_fd = f_in;
+
if (write_batch && !am_server)
start_write_batch(f_out);
flist = send_file_list(f_out, argc, argv);
if (DEBUG_GTE(FLIST, 3))
rprintf(FINFO,"file list sent\n");
+
if (protocol_version < 31 && filesfrom_host && protocol_version >= 23)
io_start_multiplex_in(f_in);
io_flush(NORMAL_FLUSH);
-
- //gettimeofday(&td, NULL); // HPZ
- long sec = 0, usec = 0;
- float time = 0;
- /*
- if((td.tv_usec-tv.tv_usec)<0){
- sec = td.tv_sec - tv.tv_sec - 1;
- usec = 1000000 +td.tv_usec - tv.tv_usec;
- }else{
- sec = td.tv_sec - tv.tv_sec;
- usec = td.tv_usec - tv.tv_usec;
- }
- time = (float)sec +(float)usec/1000000;
- printf("BE:%.4f\n", time); // HPZ: Print when end running
- */
-
-
- gettimeofday(&logtime, NULL);
- printf("[%s]:%ld.%ld\n", "send_files start", logtime.tv_sec, logtime.tv_usec);
-
send_files(f_in, f_out);
- gettimeofday(&td, NULL); // HPZ
-
- gettimeofday(&logtime, NULL);
- printf("[%s]:%ld.%ld\n", "send_files finish", logtime.tv_sec, logtime.tv_usec);
-
- /*
- //printf("%ld.%ld\n", td.tv_sec, td.tv_usec);
- //long sec = 0, usec = 0;
- if((td.tv_usec-tv.tv_usec)<0){
- sec = td.tv_sec - tv.tv_sec - 1;
- usec = 1000000 +td.tv_usec - tv.tv_usec;
- }else{
- sec = td.tv_sec - tv.tv_sec;
- usec = td.tv_usec - tv.tv_usec;
- }
- time = (float)sec +(float)usec/1000000;
- printf("AF:%.4f\n", time); // HPZ: Print when end running
- */
-
io_flush(FULL_FLUSH);
handle_stats(-1);
if (protocol_version >= 24)
@@ -1217,24 +1175,9 @@
}
output_summary();
io_flush(FULL_FLUSH);
- //struct timeval tv;
- gettimeofday(&td, NULL); // HPZ
- //long sec = 0, usec = 0;
- if((td.tv_usec-tv.tv_usec)<0){
- sec = td.tv_sec - tv.tv_sec - 1;
- usec = 1000000 +td.tv_usec - tv.tv_usec;
- }else{
- sec = td.tv_sec - tv.tv_sec;
- usec = td.tv_usec - tv.tv_usec;
- }
- time = (float)sec +(float)usec/1000000;
- //printf("%.4f,\n", time); // HPZ: Print when end running
- gettimeofday(&logtime, NULL);
- printf("[%s]:%ld.%ld\n", "RSYNC finish", logtime.tv_sec, logtime.tv_usec);
- printf("-----------------------------------\n");
exit_cleanup(exit_code);
-
}
+
if (!read_batch) {
if (protocol_version >= 23)
io_start_multiplex_in(f_in);
@@ -1245,6 +1188,7 @@
}
send_filter_list(read_batch ? -1 : f_out);
+
if (filesfrom_fd >= 0) {
start_filesfrom_forwarding(filesfrom_fd);
filesfrom_fd = -1;
@@ -1299,7 +1243,7 @@
*
* Calls either start_socket_client (for sockets) or do_cmd and
* client_run (for ssh). */
-static int start_client(int argc, char *argv[])
+static int start_client(int argc, char *argv[])
{
char *p, *shell_machine = NULL, *shell_user = NULL;
char **remote_argv;
@@ -1429,9 +1373,8 @@
}
}
- if (daemon_over_rsh < 0){
+ if (daemon_over_rsh < 0)
return start_socket_client(shell_machine, remote_argc, remote_argv, argc, argv);
- }
if (password_file && !daemon_over_rsh) {
rprintf(FERROR, "The --password-file option may only be "
@@ -1471,11 +1414,8 @@
if (tmpret < 0)
return tmpret;
}
- gettimeofday(&logtime, NULL);
- printf("[%s]:%ld.%ld\n", "client_run start", logtime.tv_sec, logtime.tv_usec);
+
ret = client_run(f_in, f_out, pid, argc, argv);
- gettimeofday(&logtime, NULL);
- printf("[%s]:%ld.%ld\n", "client_run finish", logtime.tv_sec, logtime.tv_usec);
fflush(stdout);
fflush(stderr);
@@ -1581,11 +1521,6 @@
int ret;
int orig_argc = argc;
char **orig_argv = argv;
- gettimeofday(&tv, NULL); // HPZ
- gettimeofday(&logtime, NULL);
- printf("[%s]:%ld.%ld\n", "RSYNC start", logtime.tv_sec, logtime.tv_usec);
-
-
#ifdef HAVE_SIGACTION
# ifdef HAVE_SIGPROCMASK
sigset_t sigmask;
diff -uNr rsync/match.c rsync-3.1.2/match.c
--- rsync/match.c 2016-10-07 15:03:51.783262780 -0400
+++ rsync-3.1.2/match.c 2015-08-08 15:47:03.000000000 -0400
@@ -37,8 +37,6 @@
static int total_false_alarms;
static int total_hash_hits;
static int total_matches;
-static int64 transfer_time = 0; // HPZ: This is used to detect how many times invoking a match
-static int64 meet_time = 0; // HPZ: This is used to detect how many times it hit the buffer size
extern struct stats stats;
@@ -87,12 +85,6 @@
hash_table[t] = i;
}
}
- /*
- uint32 q;
- for(q=0; q < tablesize; q++){ // HPZ: Print hash table
- if(hash_table[q]!=-1)
- printf("%d:\t%d\n", q, hash_table[q]);
- }*/
}
@@ -116,18 +108,14 @@
int32 n = (int32)(offset - last_match); /* max value: block_size (int32) */
int32 j;
- /*
- //if (DEBUG_GTE(DELTASUM, 2) && i >= 0) {
- if(i >= 0 ){
+ if (DEBUG_GTE(DELTASUM, 2) && i >= 0) {
rprintf(FINFO,
"match at %s last_match=%s j=%d len=%ld n=%ld\n",
big_num(offset), big_num(last_match), i,
(long)s->sums[i].len, (long)n);
}
- */
send_token(f, i, buf, last_match, n, i < 0 ? 0 : s->sums[i].len);
- transfer_time ++; // HPZ
data_transfer += n;
if (i >= 0) {
@@ -347,13 +335,11 @@
match. The 3 reads are caused by the
running match, the checksum update and the
literal send. */
- if (backup >= s->blength+CHUNK_SIZE && end-offset > CHUNK_SIZE){
+ if (backup >= s->blength+CHUNK_SIZE && end-offset > CHUNK_SIZE)
matched(f, s, buf, offset - s->blength, -2);
- meet_time++; // HPZ
- }
} while (++offset < end);
- matched(f, s, buf, len, -1); // HPZ : This send only 0-token-literal data
+ matched(f, s, buf, len, -1);
map_ptr(buf, len-1, 1);
}
@@ -379,8 +365,6 @@
hash_hits = 0;
matches = 0;
data_transfer = 0;
- struct timeval tv2; // HPZ start
- gettimeofday(&tv2, NULL); // HPZ
sum_init(checksum_seed);
@@ -450,21 +434,6 @@
total_false_alarms += false_alarms;
total_matches += matches;
stats.literal_data += data_transfer;
-
- struct timeval td2; // HPZ
- gettimeofday(&td2, NULL);
- long sec = 0, usec = 0;
- float time = 0;
- if((td2.tv_usec-tv2.tv_usec)<0){
- sec = td2.tv_sec - tv2.tv_sec - 1;
- usec = 1000000 +td2.tv_usec - tv2.tv_usec;
- }else{
- sec = td2.tv_sec - tv2.tv_sec;
- usec = td2.tv_usec - tv2.tv_usec;
- }
- time = (float)sec +(float)usec/1000000;
- //printf("%.4f,", time); // HPZ
-
}
void match_report(void)
@@ -472,10 +441,6 @@
if (!DEBUG_GTE(DELTASUM, 1))
return;
- printf("matched has been invoked %ld times.\n", transfer_time);
- printf("windows size has been hitted %ld times.\n", meet_time);
-
-
rprintf(FINFO,
"total: matches=%d hash_hits=%d false_alarms=%d data=%s\n",
total_matches, total_hash_hits, total_false_alarms,
diff -uNr rsync/pipe.c rsync-3.1.2/pipe.c
--- rsync/pipe.c 2016-10-05 12:41:00.931943173 -0400
+++ rsync-3.1.2/pipe.c 2015-08-08 15:47:03.000000000 -0400
@@ -175,7 +175,6 @@
*f_in = from_child_pipe[0];
*f_out = to_child_pipe[1];
- //printf("f_in:\t%d, f_out:\t%d",*f_in,*f_out); //HPZ : This never changed
return pid;
}
diff -uNr rsync/proto.h rsync-3.1.2/proto.h
--- rsync/proto.h 2016-10-07 16:25:14.123350335 -0400
+++ rsync-3.1.2/proto.h 2015-12-21 15:22:53.000000000 -0500
@@ -253,7 +253,7 @@
void read_del_stats(int f);
int child_main(int argc, char *argv[]);
void start_server(int f_in, int f_out, int argc, char *argv[]);
-int client_run(int f_in, int f_out, pid_t pid, int argc, char *argv[]) ;
+int client_run(int f_in, int f_out, pid_t pid, int argc, char *argv[]);
void remember_children(UNUSED(int val));
const char *get_panic_action(void);
int main(int argc,char *argv[]);
@@ -399,7 +399,6 @@
const char *sum_as_hex(const char *sum);
NORETURN void out_of_memory(const char *str);
NORETURN void overflow_exit(const char *str);
-void print(char *msg);
void free_xattr(stat_x *sxp);
int get_xattr(const char *fname, stat_x *sxp);
int copy_xattrs(const char *source, const char *dest);
diff -uNr rsync/rsync.c rsync-3.1.2/rsync.c
--- rsync/rsync.c 2016-10-07 15:50:15.478230583 -0400
+++ rsync-3.1.2/rsync.c 2015-08-08 15:47:03.000000000 -0400
@@ -317,7 +317,6 @@
read_loop:
while (1) {
-
ndx = read_ndx(f_in);
if (ndx >= 0)
@@ -369,7 +368,7 @@
flist->parent_ndx = ndx;
stop_flist_forward();
}
-
+
iflags = protocol_version >= 29 ? read_shortint(f_in)
: ITEM_TRANSFER | ITEM_MISSING_DATA;
@@ -750,4 +749,3 @@
: am_receiver ? "receiver"
: "Receiver"; /* pre-forked receiver */
}
-
diff -uNr rsync/rsync.h rsync-3.1.2/rsync.h
--- rsync/rsync.h 2016-10-07 16:24:23.365209158 -0400
+++ rsync-3.1.2/rsync.h 2015-08-08 15:47:03.000000000 -0400
@@ -705,8 +705,6 @@
const char basename[1]; /* The basename (AKA filename) follows */
};
-struct timeval logtime; // HPZ: This is very useful log timestamp
-
extern int file_extra_cnt;
extern int inc_recurse;
extern int uid_ndx;
diff -uNr rsync/sender.c rsync-3.1.2/sender.c
--- rsync/sender.c 2016-10-07 15:31:56.633777127 -0400
+++ rsync-3.1.2/sender.c 2015-09-07 13:07:17.000000000 -0400
@@ -206,8 +206,6 @@
if (DEBUG_GTE(SEND, 1))
rprintf(FINFO, "send_files starting\n");
- int tmpflag=0; // HPZ: I'm so stupid
- struct timeval tv3, td3;
while (1) {
if (inc_recurse) {
send_extra_file_list(f_out, MIN_FILECNT_LOOKAHEAD);
@@ -215,16 +213,9 @@
}
/* This call also sets cur_flist. */
- gettimeofday(&logtime, NULL);
- printf("[%s]:%ld.%ld\n", "rw_ndx start", logtime.tv_sec, logtime.tv_usec);
ndx = read_ndx_and_attrs(f_in, f_out, &iflags, &fnamecmp_type,
- xname, &xlen); // HPZ: Figure out this!
-
+ xname, &xlen);
extra_flist_sending_enabled = False;
- //printf("ndx:%d\n", ndx);
- /*
- From here
- */
if (ndx == NDX_DONE) {
if (!am_server && INFO_GTE(PROGRESS, 2) && cur_flist) {
@@ -241,24 +232,16 @@
continue;
}
}
- if (++phase > max_phase){
+ if (++phase > max_phase)
break;
- }
if (DEBUG_GTE(SEND, 1))
rprintf(FINFO, "send_files phase=%d\n", phase);
- write_ndx(f_out, NDX_DONE); // HPZ: Due to phase, it will run twice. so WHAT's WRITE_NDX
+ write_ndx(f_out, NDX_DONE);
continue;
- }
- gettimeofday(&logtime, NULL);
- printf("[%s]:%ld.%ld\n", "rw_ndx finish", logtime.tv_sec, logtime.tv_usec);
-
- /*
- to here
- */
-
+ }
+
if (inc_recurse)
send_extra_file_list(f_out, MIN_FILECNT_LOOKAHEAD);
- // printf("****************************%d\n",ndx);
if (ndx - cur_flist->ndx_start >= 0)
file = cur_flist->files[ndx - cur_flist->ndx_start];
@@ -273,14 +256,16 @@
if (!change_pathname(file, NULL, 0))
continue;
f_name(file, fname);
+
if (DEBUG_GTE(SEND, 1))
rprintf(FINFO, "send_files(%d, %s%s%s)\n", ndx, path,slash,fname);
-
+
#ifdef SUPPORT_XATTRS
if (preserve_xattrs && iflags & ITEM_REPORT_XATTR && do_xfers
&& !(want_xattr_optim && BITS_SET(iflags, ITEM_XNAME_FOLLOWS|ITEM_LOCAL_CHANGE)))
recv_xattr_request(file, f_in);
#endif
+
if (!(iflags & ITEM_TRANSFER)) {
maybe_log_item(file, iflags, itemizing, xname);
write_ndx_and_attrs(f_out, ndx, iflags, fname, file,
@@ -308,6 +293,7 @@
who_am_i());
exit_cleanup(RERR_PROTOCOL);
}
+
if (file->flags & FLAG_FILE_SENT) {
if (csum_length == SHORT_SUM_LENGTH) {
/* For inplace: redo phase turns off the backup
@@ -325,6 +311,7 @@
if (iflags & ITEM_IS_NEW)
stats.created_files++;
}
+
updating_basis_file = inplace && (protocol_version >= 29
? fnamecmp_type == FNAMECMP_FNAME : make_backups <= 0);
@@ -341,13 +328,13 @@
fnamecmp_type, xname, xlen);
continue;
}
-
+
if (!(s = receive_sums(f_in))) {
io_error |= IOERR_GENERAL;
rprintf(FERROR_XFER, "receive_sums failed\n");
exit_cleanup(RERR_PROTOCOL);
}
-
+
fd = do_open(fname, O_RDONLY, 0);
if (fd == -1) {
if (errno == ENOENT) {
@@ -368,6 +355,7 @@
send_msg_int(MSG_NO_SEND, ndx);
continue;
}
+
/* map the local file */
if (do_fstat(fd, &st) != 0) {
io_error |= IOERR_GENERAL;
@@ -383,7 +371,7 @@
} else
mbuf = NULL;
- if (DEBUG_GTE(DELTASUM, 2)){
+ if (DEBUG_GTE(DELTASUM, 2)) {
rprintf(FINFO, "send_files mapped %s%s%s of size %s\n",
path,slash,fname, big_num(st.st_size));
}
@@ -391,6 +379,7 @@
write_ndx_and_attrs(f_out, ndx, iflags, fname, file,
fnamecmp_type, xname, xlen);
write_sum_head(f_xfer, s);
+
if (DEBUG_GTE(DELTASUM, 2))
rprintf(FINFO, "calling match_sums %s%s%s\n", path,slash,fname);
@@ -400,15 +389,8 @@
rprintf(FCLIENT, "%s\n", fname);
set_compression(fname);
-
-
- gettimeofday(&logtime, NULL);
- printf("[%s]:%ld.%ld\n", "match_sum start", logtime.tv_sec, logtime.tv_usec);
- match_sums(f_xfer, s, mbuf, st.st_size);
- gettimeofday(&logtime, NULL);
- printf("[%s]:%ld.%ld\n", "match_sum finish", logtime.tv_sec, logtime.tv_usec);
- match_report();
+ match_sums(f_xfer, s, mbuf, st.st_size);
if (INFO_GTE(PROGRESS, 1))
end_progress(st.st_size);
@@ -424,6 +406,7 @@
}
}
close(fd);
+
free_sums(s);
if (DEBUG_GTE(SEND, 1))
@@ -432,7 +415,6 @@
/* Flag that we actually sent this entry. */
file->flags |= FLAG_FILE_SENT;
}
-
if (make_backups < 0)
make_backups = -make_backups;
@@ -442,7 +424,7 @@
if (DEBUG_GTE(SEND, 1))
rprintf(FINFO, "send files finished\n");
- // Match_report suppose to be here.
+ match_report();
write_ndx(f_out, NDX_DONE);
}
diff -uNr rsync/util2.c rsync-3.1.2/util2.c
--- rsync/util2.c 2016-10-07 16:25:30.710777685 -0400
+++ rsync-3.1.2/util2.c 2015-08-08 15:47:03.000000000 -0400
@@ -111,8 +111,3 @@
rprintf(FERROR, "ERROR: buffer overflow in %s [%s]\n", str, who_am_i());
exit_cleanup(RERR_MALLOC);
}
-
-void print(char *msg)
-{
- printf("%s\n", msg);
- }
diff -uNr rsync/util.c rsync-3.1.2/util.c
--- rsync/util.c 2016-10-07 16:16:49.961215701 -0400
+++ rsync-3.1.2/util.c 2015-12-21 13:54:02.000000000 -0500
@@ -1645,4 +1645,3 @@
}
return (char*)lp->items + (lp->count++ * item_size);
}
-