Matt McCutchen's Web Site
/
rsync
/
rsync.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
We need to call msg2sndr_flush() in read_msg_fd() now.
[rsync/rsync.git]
/
io.c
diff --git
a/io.c
b/io.c
index
e2304d4
..
567065b
100644
(file)
--- a/
io.c
+++ b/
io.c
@@
-107,7
+107,8
@@
static char int_byte_cnt[64] = {
5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 8, 9, /* (C0 - FF)/4 */
};
5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 8, 9, /* (C0 - FF)/4 */
};
-static int readfd_unbuffered(int fd, char *buf, size_t len);
+static void msg2sndr_flush(void);
+static void readfd(int fd, char *buffer, size_t N);
static void writefd(int fd, const char *buf, size_t len);
static void writefd_unbuffered(int fd, const char *buf, size_t len);
static void decrement_active_files(int ndx);
static void writefd(int fd, const char *buf, size_t len);
static void writefd_unbuffered(int fd, const char *buf, size_t len);
static void decrement_active_files(int ndx);
@@
-263,8
+264,9
@@
static void read_msg_fd(void)
/* Temporarily disable msg_fd_in. This is needed to avoid looping back
* to this routine from writefd_unbuffered(). */
msg_fd_in = -1;
/* Temporarily disable msg_fd_in. This is needed to avoid looping back
* to this routine from writefd_unbuffered(). */
msg_fd_in = -1;
+ defer_forwarding_messages++;
- readfd
_unbuffered
(fd, buf, 4);
+ readfd(fd, buf, 4);
tag = IVAL(buf, 0);
len = tag & 0xFFFFFF;
tag = IVAL(buf, 0);
len = tag & 0xFFFFFF;
@@
-284,7
+286,7
@@
static void read_msg_fd(void)
case MSG_REDO:
if (len != 4 || !am_generator)
goto invalid_msg;
case MSG_REDO:
if (len != 4 || !am_generator)
goto invalid_msg;
- readfd
_unbuffered
(fd, buf, 4);
+ readfd(fd, buf, 4);
if (remove_source_files)
decrement_active_files(IVAL(buf,0));
flist_ndx_push(&redo_list, IVAL(buf,0));
if (remove_source_files)
decrement_active_files(IVAL(buf,0));
flist_ndx_push(&redo_list, IVAL(buf,0));
@@
-294,7
+296,7
@@
static void read_msg_fd(void)
case MSG_FLIST:
if (len != 4 || !am_generator || !incremental)
goto invalid_msg;
case MSG_FLIST:
if (len != 4 || !am_generator || !incremental)
goto invalid_msg;
- readfd
_unbuffered
(fd, buf, 4);
+ readfd(fd, buf, 4);
/* Read extra file list from receiver. */
assert(iobuf_in != NULL);
assert(iobuf_f_in == fd);
/* Read extra file list from receiver. */
assert(iobuf_in != NULL);
assert(iobuf_f_in == fd);
@@
-309,13
+311,13
@@
static void read_msg_fd(void)
case MSG_DELETED:
if (len >= (int)sizeof buf || !am_generator)
goto invalid_msg;
case MSG_DELETED:
if (len >= (int)sizeof buf || !am_generator)
goto invalid_msg;
- readfd
_unbuffered
(fd, buf, len);
+ readfd(fd, buf, len);
send_msg(MSG_DELETED, buf, len);
break;
case MSG_SUCCESS:
if (len != 4 || !am_generator)
goto invalid_msg;
send_msg(MSG_DELETED, buf, len);
break;
case MSG_SUCCESS:
if (len != 4 || !am_generator)
goto invalid_msg;
- readfd
_unbuffered
(fd, buf, len);
+ readfd(fd, buf, len);
if (remove_source_files) {
decrement_active_files(IVAL(buf,0));
send_msg(MSG_SUCCESS, buf, len);
if (remove_source_files) {
decrement_active_files(IVAL(buf,0));
send_msg(MSG_SUCCESS, buf, len);
@@
-328,7
+330,7
@@
static void read_msg_fd(void)
case MSG_NO_SEND:
if (len != 4 || !am_generator)
goto invalid_msg;
case MSG_NO_SEND:
if (len != 4 || !am_generator)
goto invalid_msg;
- readfd
_unbuffered
(fd, buf, len);
+ readfd(fd, buf, len);
if (incremental)
decrement_flist_in_progress(IVAL(buf,0), 0);
break;
if (incremental)
decrement_flist_in_progress(IVAL(buf,0), 0);
break;
@@
-346,7
+348,7
@@
static void read_msg_fd(void)
n = len;
if (n >= sizeof buf)
n = sizeof buf - 1;
n = len;
if (n >= sizeof buf)
n = sizeof buf - 1;
- readfd
_unbuffered
(fd, buf, n);
+ readfd(fd, buf, n);
rwrite((enum logcode)tag, buf, n);
len -= n;
}
rwrite((enum logcode)tag, buf, n);
len -= n;
}
@@
-357,7
+359,9
@@
static void read_msg_fd(void)
exit_cleanup(RERR_STREAMIO);
}
exit_cleanup(RERR_STREAMIO);
}
+ defer_forwarding_messages--;
msg_fd_in = fd;
msg_fd_in = fd;
+ msg2sndr_flush();
}
/* This is used by the generator to limit how many file transfers can
}
/* This is used by the generator to limit how many file transfers can
@@
-417,7
+421,7
@@
static void decrement_flist_in_progress(int ndx, int redo)
* This is only active in the receiver. */
static int msg2genr_flush(void)
{
* This is only active in the receiver. */
static int msg2genr_flush(void)
{
- if (msg_fd_out < 0 || no_flush)
+ if (msg_fd_out < 0 || no_flush
|| flist_forward_from >= 0
)
return -1;
no_flush++;
return -1;
no_flush++;
@@
-538,7
+542,7
@@
static int read_timeout(int fd, char *buf, size_t len)
{
int n, cnt = 0;
{
int n, cnt = 0;
- io_flush(
NORMA
L_FLUSH);
+ io_flush(
FUL
L_FLUSH);
while (cnt == 0) {
/* until we manage to read *something* */
while (cnt == 0) {
/* until we manage to read *something* */
@@
-818,8
+822,8
@@
void start_flist_forward(int f_in)
void stop_flist_forward()
{
void stop_flist_forward()
{
- io_flush(NORMAL_FLUSH);
flist_forward_from = -1;
flist_forward_from = -1;
+ io_flush(FULL_FLUSH);
}
/**
}
/**
@@
-947,11
+951,8
@@
static int readfd_unbuffered(int fd, char *buf, size_t len)
return cnt;
}
return cnt;
}
-/**
- * Do a buffered read from @p fd. Don't return until all @p n bytes
- * have been read. If all @p n can't be read then exit with an
- * error.
- **/
+/* Do a buffered read from fd. Don't return until all N bytes have
+ * been read. If all N can't be read then exit with an error. */
static void readfd(int fd, char *buffer, size_t N)
{
int cnt;
static void readfd(int fd, char *buffer, size_t N)
{
int cnt;
@@
-1345,10
+1346,12
@@
static void mplex_write(enum msgcode code, const char *buf, size_t len)
}
}
}
}
-void io_flush(
UNUSED(int flush_it_all)
)
+void io_flush(
int flush_it_all
)
{
{
- msg2genr_flush();
- msg2sndr_flush();
+ if (flush_it_all) {
+ msg2genr_flush();
+ msg2sndr_flush();
+ }
if (!iobuf_out_cnt || no_flush)
return;
if (!iobuf_out_cnt || no_flush)
return;