summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
08f1533)
connections (this fixes the stderr/stdout problem). Upped
protocol version for backward compat
- use multiplexing on error fd
- upped minimal protocol version
- got rid of some ugly code in the write buffering
- if (remote_version >= 22 || (remote_version > 17 && !am_sender))
+ if (remote_version == 22 || (remote_version > 17 && !am_sender))
io_start_multiplex_in(fd);
return client_run(fd, fd, -1, argc, argv);
io_start_multiplex_in(fd);
return client_run(fd, fd, -1, argc, argv);
argp = argv + optind;
optind = 0;
argp = argv + optind;
optind = 0;
- if (remote_version >= 22 || (remote_version > 17 && am_sender))
+ if (remote_version == 22 || (remote_version > 17 && am_sender))
io_start_multiplex_out(fd);
if (read_only) {
io_start_multiplex_out(fd);
if (read_only) {
static int buffer_f_in = -1;
static int io_error_fd = -1;
static int buffer_f_in = -1;
static int io_error_fd = -1;
+static void read_loop(int fd, char *buf, int len);
+
void setup_readbuffer(int f_in)
{
buffer_f_in = f_in;
void setup_readbuffer(int f_in)
{
buffer_f_in = f_in;
-/* read some data from the error fd and write it to FERROR */
+/* read some data from the error fd and write it to the write log code */
static void read_error_fd(void)
{
char buf[200];
int n;
int fd = io_error_fd;
static void read_error_fd(void)
{
char buf[200];
int n;
int fd = io_error_fd;
- n = read(fd, buf, sizeof(buf)-1);
- if (n > 0) {
- rwrite(FERROR, buf, n);
+ read_loop(fd, buf, 4);
+ tag = IVAL(buf, 0);
+
+ len = tag & 0xFFFFFF;
+ tag = tag >> 24;
+ tag -= MPLEX_BASE;
+
+ while (len) {
+ n = len;
+ if (n > (sizeof(buf)-1)) n = sizeof(buf)-1;
+ read_loop(fd, buf, n);
+ rwrite((enum logcode)tag, buf, n);
+ len -= n;
static int read_unbuffered(int fd, char *buf, int len)
{
static int remaining;
static int read_unbuffered(int fd, char *buf, int len)
{
static int remaining;
int tag, ret=0;
char line[1024];
int tag, ret=0;
char line[1024];
- read_loop(fd, ibuf, 4);
- tag = IVAL(ibuf, 0);
+ read_loop(fd, line, 4);
+ tag = IVAL(line, 0);
remaining = tag & 0xFFFFFF;
tag = tag >> 24;
remaining = tag & 0xFFFFFF;
tag = tag >> 24;
read_loop(fd, line, remaining);
line[remaining] = 0;
read_loop(fd, line, remaining);
line[remaining] = 0;
- rprintf(tag,"%s", line);
+ rprintf((enum logcode)tag,"%s", line);
{
if (io_buffer) return;
multiplex_out_fd = fd;
{
if (io_buffer) return;
multiplex_out_fd = fd;
- io_buffer = (char *)malloc(IO_BUFFER_SIZE+4);
+ io_buffer = (char *)malloc(IO_BUFFER_SIZE);
if (!io_buffer) out_of_memory("writefd");
io_buffer_count = 0;
if (!io_buffer) out_of_memory("writefd");
io_buffer_count = 0;
+}
+
+/* write an message to a multiplexed stream. If this fails then rsync
+ exits */
+static void mplex_write(int fd, enum logcode code, char *buf, int len)
+{
+ char buffer[4096];
+ int n = len;
- /* leave room for the multiplex header in case it's needed */
- io_buffer += 4;
+ SIVAL(buffer, 0, ((MPLEX_BASE + (int)code)<<24) + len);
+
+ if (n > (sizeof(buf)-4)) {
+ n = sizeof(buf)-4;
+ }
+
+ memcpy(&buffer[4], buf, n);
+ writefd_unbuffered(fd, buffer, n+4);
+
+ len -= n;
+ buf += n;
+
+ writefd_unbuffered(fd, buf, len);
void io_flush(void)
{
int fd = multiplex_out_fd;
if (!io_buffer_count || no_flush) return;
if (io_multiplexing_out) {
void io_flush(void)
{
int fd = multiplex_out_fd;
if (!io_buffer_count || no_flush) return;
if (io_multiplexing_out) {
- SIVAL(io_buffer-4, 0, (MPLEX_BASE<<24) + io_buffer_count);
- writefd_unbuffered(fd, io_buffer-4, io_buffer_count+4);
+ mplex_write(fd, 0, io_buffer, io_buffer_count);
} else {
writefd_unbuffered(fd, io_buffer, io_buffer_count);
}
} else {
writefd_unbuffered(fd, io_buffer, io_buffer_count);
}
{
io_flush();
if (!io_multiplexing_out) {
{
io_flush();
if (!io_multiplexing_out) {
}
/* write an message to the multiplexed error stream */
}
/* write an message to the multiplexed error stream */
-int io_multiplex_write(int f, char *buf, int len)
+int io_multiplex_write(enum logcode code, char *buf, int len)
{
if (!io_multiplexing_out) return 0;
io_flush();
{
if (!io_multiplexing_out) return 0;
io_flush();
-
- SIVAL(io_buffer-4, 0, ((MPLEX_BASE + f)<<24) + len);
- memcpy(io_buffer, buf, len);
-
stats.total_written += (len+4);
stats.total_written += (len+4);
-
- writefd_unbuffered(multiplex_out_fd, io_buffer-4, len+4);
+ mplex_write(multiplex_out_fd, code, buf, len);
return 1;
}
/* write a message to the special error fd */
return 1;
}
/* write a message to the special error fd */
-int io_error_write(int f, char *buf, int len)
+int io_error_write(int f, enum logcode code, char *buf, int len)
- writefd_unbuffered(f, buf, len);
+ mplex_write(f, code, buf, len);
/* this is the underlying (unformatted) rsync debugging function. Call
it with FINFO, FERROR or FLOG */
/* this is the underlying (unformatted) rsync debugging function. Call
it with FINFO, FERROR or FLOG */
-void rwrite(int fd, char *buf, int len)
+void rwrite(enum logcode code, char *buf, int len)
{
FILE *f=NULL;
extern int am_daemon;
extern int quiet;
/* recursion can happen with certain fatal conditions */
{
FILE *f=NULL;
extern int am_daemon;
extern int quiet;
/* recursion can happen with certain fatal conditions */
- if (quiet != 0 && fd == FINFO) return;
+ if (quiet != 0 && code == FINFO) return;
if (len < 0) exit_cleanup(RERR_MESSAGEIO);
buf[len] = 0;
if (len < 0) exit_cleanup(RERR_MESSAGEIO);
buf[len] = 0;
if (am_daemon) logit(LOG_INFO, buf);
return;
}
if (am_daemon) logit(LOG_INFO, buf);
return;
}
+ if (io_error_write(log_error_fd, code, buf, strlen(buf))) return;
+
if (am_daemon) {
static int depth;
int priority = LOG_INFO;
if (am_daemon) {
static int depth;
int priority = LOG_INFO;
- if (fd == FERROR) priority = LOG_WARNING;
+ if (code == FERROR) priority = LOG_WARNING;
if (depth) return;
depth++;
log_open();
if (depth) return;
depth++;
log_open();
-
- if (!io_error_write(log_error_fd, buf, strlen(buf)) &&
- !io_multiplex_write(fd, buf, strlen(buf))) {
+ if (!io_multiplex_write(code, buf, strlen(buf))) {
extern int am_server;
if (am_server)
f = stderr;
extern int am_server;
if (am_server)
f = stderr;
/* this is the rsync debugging function. Call it with FINFO, FERROR or FLOG */
/* this is the rsync debugging function. Call it with FINFO, FERROR or FLOG */
- void rprintf(int fd, const char *format, ...)
+ void rprintf(enum logcode code, const char *format, ...)
{
va_list ap;
char buf[1024];
{
va_list ap;
char buf[1024];
if (len > sizeof(buf)-1) exit_cleanup(RERR_MESSAGEIO);
if (len > sizeof(buf)-1) exit_cleanup(RERR_MESSAGEIO);
+ rwrite(code, buf, len);
+void rflush(enum logcode code)
{
FILE *f = NULL;
extern int am_daemon;
{
FILE *f = NULL;
extern int am_daemon;
extern int am_server;
if (am_server)
f = stderr;
extern int am_server;
if (am_server)
f = stderr;
{
extern int cvs_exclude;
extern int am_sender;
{
extern int cvs_exclude;
extern int am_sender;
+ extern int remote_version;
+
+ if (remote_version >= 23)
+ io_start_multiplex_out(f_out);
setup_protocol(f_out, f_in);
setup_protocol(f_out, f_in);
char *local_name = NULL;
extern int am_sender;
extern int list_only;
char *local_name = NULL;
extern int am_sender;
extern int list_only;
+ extern int remote_version;
+
+ if (remote_version >= 23)
+ io_start_multiplex_in(f_in);
setup_protocol(f_out,f_in);
setup_protocol(f_out,f_in);
#define SAME_TIME (1<<7)
/* update this if you make incompatible changes */
#define SAME_TIME (1<<7)
/* update this if you make incompatible changes */
-#define PROTOCOL_VERSION 22
-#define MIN_PROTOCOL_VERSION 11
+#define PROTOCOL_VERSION 23
+#define MIN_PROTOCOL_VERSION 15
#define MAX_PROTOCOL_VERSION 30
#define RSYNC_PORT 873
#define MAX_PROTOCOL_VERSION 30
#define RSYNC_PORT 873
#define MAX_ARGS 1000
#define MPLEX_BASE 7
#define MAX_ARGS 1000
#define MPLEX_BASE 7
-#define FERROR 1
-#define FINFO 2
-#define FLOG 3
+
+enum logcode {FERROR=1, FINFO=2, FLOG=3};
#define NS(s) ((s)?(s):"<NULL>")
/* use magic gcc attributes to catch format errors */
#define NS(s) ((s)?(s):"<NULL>")
/* use magic gcc attributes to catch format errors */
- void rprintf(int , const char *, ...)
+ void rprintf(enum logcode , const char *, ...)
#ifdef __GNUC__
__attribute__ ((format (printf, 2, 3)))
#endif
#ifdef __GNUC__
__attribute__ ((format (printf, 2, 3)))
#endif
rm -rf ${TO}
mkdir -p ${FROM}2/dir/subdir
cp -a ${FROM}/dir/subdir/subsubdir ${FROM}2/dir/subdir
rm -rf ${TO}
mkdir -p ${FROM}2/dir/subdir
cp -a ${FROM}/dir/subdir/subsubdir ${FROM}2/dir/subdir
-cp ${FROM}/dir/* ${FROM}2/dir 2>/dev/null
+cp -a ${FROM}/dir/* ${FROM}2/dir 2>/dev/null
runtest "excludes" 'checkit "rsync -vv -Hlrt --delete --include /dir/ --include /dir/\* --include /dir/\*/subsubdir --include /dir/\*/subsubdir/\*\* --exclude \*\* ${FROM}/dir ${TO}" ${FROM}2/ ${TO}'
rm -r ${FROM}2
runtest "excludes" 'checkit "rsync -vv -Hlrt --delete --include /dir/ --include /dir/\* --include /dir/\*/subsubdir --include /dir/\*/subsubdir/\*\* --exclude \*\* ${FROM}/dir ${TO}" ${FROM}2/ ${TO}'
rm -r ${FROM}2