FD_SET(msg_fd_in, &r_fds);
if (msg_fd_in >= fd_count)
fd_count = msg_fd_in+1;
+ } else if (msg_list_head) {
+ FD_SET(msg_fd_out, &w_fds);
+ if (msg_fd_out >= fd_count)
+ fd_count = msg_fd_out+1;
}
if (io_filesfrom_f_out >= 0) {
int new_fd;
io_filesfrom_buflen? &w_fds : NULL,
NULL, &tv);
- if (count == 0) {
- msg_list_push(NORMAL_FLUSH);
- check_timeout();
- }
-
if (count <= 0) {
+ check_timeout();
if (errno == EBADF)
exit_cleanup(RERR_SOCKETIO);
continue;
if (msg_fd_in >= 0 && FD_ISSET(msg_fd_in, &r_fds))
read_msg_fd();
+ else if (msg_list_head && FD_ISSET(msg_fd_out, &w_fds))
+ msg_list_push(NORMAL_FLUSH);
if (io_filesfrom_f_out >= 0) {
if (io_filesfrom_buflen) {
int fd_count, count;
struct timeval tv;
- msg_list_push(NORMAL_FLUSH);
+ if (fd == msg_fd_out) {
+ rprintf(FERROR, "Internal error: wrong write used in receiver.\n");
+ exit_cleanup(RERR_PROTOCOL);
+ }
no_flush++;
count = select(fd_count+1, msg_fd_in >= 0 ? &r_fds : NULL,
&w_fds, NULL, &tv);
- if (count == 0) {
- msg_list_push(NORMAL_FLUSH);
- check_timeout();
- }
-
if (count <= 0) {
+ check_timeout();
if (errno == EBADF)
exit_cleanup(RERR_SOCKETIO);
continue;
{
stats.total_written += len;
- msg_list_push(NORMAL_FLUSH);
+ if (fd == msg_fd_out) {
+ rprintf(FERROR, "Internal error: wrong write used in receiver.\n");
+ exit_cleanup(RERR_PROTOCOL);
+ }
if (!io_buffer || fd != multiplex_out_fd) {
writefd_unbuffered(fd, buf, len);