1 --- io.c 16 Jan 2004 16:31:47 -0000 1.119
2 +++ io.c 2004-04-19 16:07:57.000000000 -0400
3 @@ -47,6 +47,7 @@ static time_t last_io;
11 @@ -759,6 +760,26 @@ static void sleep_for_bwlimit(int bytes_
12 select(0, NULL, NULL, NULL, &tv);
16 + * When --timelimit is used, compare rsync_start_time and the current time
17 + * and return 1 when the timelimit has been reached.
19 +static int has_timelimit_expired()
22 + time_t start_time = 0;
23 + time_t expiration_time = 0;
25 + assert(timelimit > 0);
27 + start_time = get_rsync_start_time();
28 + assert(start_time > 0);
30 + gettimeofday(&tv, NULL);
31 + expiration_time = start_time + (timelimit * 60);
33 + return tv.tv_sec > expiration_time;
37 * Write len bytes to the file descriptor @p fd.
38 @@ -837,6 +858,11 @@ static void writefd_unbuffered(int fd,ch
41 sleep_for_bwlimit(ret);
43 + if (timelimit && has_timelimit_expired()) {
44 + rprintf(FERROR, RSYNC_NAME ": \n%d minute time limit exceeded.\n", timelimit);
45 + exit_cleanup(RERR_PARTIAL);
50 --- options.c 17 Apr 2004 17:07:23 -0000 1.147
51 +++ options.c 2004-04-19 16:07:57.000000000 -0400
52 @@ -83,6 +83,7 @@ int safe_symlinks = 0;
53 int copy_unsafe_links = 0;
58 int only_existing = 0;
59 int opt_ignore_existing = 0;
60 @@ -288,6 +289,7 @@ void usage(enum logcode F)
61 rprintf(F," --log-format=FORMAT log file transfers using specified format\n");
62 rprintf(F," --password-file=FILE get password from FILE\n");
63 rprintf(F," --bwlimit=KBPS limit I/O bandwidth, KBytes per second\n");
64 + rprintf(F," --timelimit=MINS Stop rsync after MINS minutes\n");
65 rprintf(F," --write-batch=PREFIX write batch fileset starting with PREFIX\n");
66 rprintf(F," --read-batch=PREFIX read batch fileset starting with PREFIX\n");
67 rprintf(F," -h, --help show this help screen\n");
68 @@ -377,6 +379,7 @@ static struct poptOption long_options[]
69 {"port", 0, POPT_ARG_INT, &rsync_port, 0, 0, 0 },
70 {"log-format", 0, POPT_ARG_STRING, &log_format, 0, 0, 0 },
71 {"bwlimit", 0, POPT_ARG_INT, &bwlimit, 0, 0, 0 },
72 + {"timelimit", 0, POPT_ARG_INT, &timelimit, 0, 0, 0 },
73 {"address", 0, POPT_ARG_STRING, &bind_address, 0, 0, 0 },
74 {"backup-dir", 0, POPT_ARG_STRING, &backup_dir, 0, 0, 0 },
75 {"hard-links", 'H', POPT_ARG_NONE, &preserve_hard_links, 0, 0, 0 },
76 @@ -881,6 +884,12 @@ void server_options(char **args,int *arg
79 if (asprintf(&arg, "--bwlimit=%d", bwlimit) < 0)
85 + if (asprintf(&arg, "--timelimit=%d", timelimit) < 0)
89 --- proto.h 22 Apr 2004 09:58:09 -0000 1.189
90 +++ proto.h 2004-04-19 16:07:57.000000000 -0400
91 @@ -266,6 +266,7 @@ int u_strcmp(const char *cs1, const char
92 int unsafe_symlink(const char *dest, const char *src);
93 char *timestring(time_t t);
95 +time_t get_rsync_start_time(void);
96 int cmp_modtime(time_t file1, time_t file2);
97 int _Insure_trap_error(int a1, int a2, int a3, int a4, int a5, int a6);
98 void *_new_array(unsigned int size, unsigned long num);
99 --- rsync.yo 22 Apr 2004 21:35:45 -0000 1.161
100 +++ rsync.yo 19 Apr 2004 20:50:45 -0000
101 @@ -346,6 +346,7 @@ verb(
102 --log-format=FORMAT log file transfers using specified format
103 --password-file=FILE get password from FILE
104 --bwlimit=KBPS limit I/O bandwidth, KBytes per second
105 + --timelimit=MINS Stop rsync after MINS minutes
106 --write-batch=PREFIX write batch fileset starting with PREFIX
107 --read-batch=PREFIX read batch fileset starting with PREFIX
108 -h, --help show this help screen
109 @@ -883,6 +884,10 @@ of rsync transfers, blocks of data are s
110 transfer was too fast, it will wait before sending the next data block. The
111 result is an average transfer rate equaling the specified limit. A value
112 of zero specifies no limit.
114 +dit(bf(--timelimit=MINS)) This option allows you to specify the maximum
115 +number of minutes rsync will run for. Ths time starts when the first
116 +file starts transferring.
118 dit(bf(--write-batch=PREFIX)) Generate a set of files that can be
119 transferred as a batch update. Each filename in the set starts with
120 --- util.c 22 Apr 2004 22:17:15 -0000 1.138
121 +++ util.c 2004-04-19 16:07:57.000000000 -0400
122 @@ -1049,6 +1049,21 @@ int msleep(int t)
127 + * Return the time that rsync is started, used by --time-limit
129 +time_t get_rsync_start_time(void)
131 + static struct timeval tval;
132 + static int has_set_rsync_start_time = 0;
134 + if (!has_set_rsync_start_time) {
135 + gettimeofday(&tval, NULL);
136 + has_set_rsync_start_time = 1;
139 + return tval.tv_sec;
143 * Determine if two file modification times are equivalent (either