by a read during an io_flush() triggered during a readfd(). A simple
logic bug in the io code :(
static int read_buffer_len;
static int read_buffer_size;
static int no_flush;
static int read_buffer_len;
static int read_buffer_size;
static int no_flush;
+static int no_flush_read;
/* read from a socket with IO timeout. return the number of
bytes read. If no bytes can be read then exit, never return
/* read from a socket with IO timeout. return the number of
bytes read. If no bytes can be read then exit, never return
while (ret == 0) {
fd_set fds;
while (ret == 0) {
fd_set fds;
ret = read_unbuffered(fd,buffer + total,N-total);
total += ret;
ret = read_unbuffered(fd,buffer + total,N-total);
total += ret;
fd_set w_fds, r_fds;
int fd_count, count;
struct timeval tv;
fd_set w_fds, r_fds;
int fd_count, count;
struct timeval tv;
int blocked=0;
no_flush++;
int blocked=0;
no_flush++;
FD_SET(fd,&w_fds);
fd_count = fd+1;
FD_SET(fd,&w_fds);
fd_count = fd+1;
- reading = (buffer_f_in != -1 &&
- read_buffer_len < MAX_READ_BUFFER);
+ if (!no_flush_read) {
+ reading = (buffer_f_in != -1 &&
+ read_buffer_len < MAX_READ_BUFFER);
+ }
if (reading) {
FD_SET(buffer_f_in,&r_fds);
if (reading) {
FD_SET(buffer_f_in,&r_fds);
if (!get_tmpname(fnametmp,fname)) {
if (buf) unmap_file(buf);
if (!get_tmpname(fnametmp,fname)) {
if (buf) unmap_file(buf);
+ if (fd1 != -1) close(fd1);
rprintf(FERROR,"mktemp %s failed\n",fnametmp);
receive_data(f_in,buf,-1,NULL,file->length);
if (buf) unmap_file(buf);
rprintf(FERROR,"mktemp %s failed\n",fnametmp);
receive_data(f_in,buf,-1,NULL,file->length);
if (buf) unmap_file(buf);
+ if (fd1 != -1) close(fd1);
rprintf(FERROR,"open %s : %s\n",fnametmp,strerror(errno));
receive_data(f_in,buf,-1,NULL,file->length);
if (buf) unmap_file(buf);
rprintf(FERROR,"open %s : %s\n",fnametmp,strerror(errno));
receive_data(f_in,buf,-1,NULL,file->length);
if (buf) unmap_file(buf);
+ if (fd1 != -1) close(fd1);
/* detach from the terminal */
#ifdef HAVE_SETSID
setsid();
#else
#ifdef TIOCNOTTY
/* detach from the terminal */
#ifdef HAVE_SETSID
setsid();
#else
#ifdef TIOCNOTTY
- {
- int i = open("/dev/tty", O_RDWR);
- if (i >= 0)
- {
- ioctl(i, (int) TIOCNOTTY, (char *)0);
- close(i);
- }
+ i = open("/dev/tty", O_RDWR);
+ if (i >= 0) {
+ ioctl(i, (int) TIOCNOTTY, (char *)0);
+ close(i);
}
#endif /* TIOCNOTTY */
#endif
}
#endif /* TIOCNOTTY */
#endif
}
ofd = do_open(dest, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, mode);
}
ofd = do_open(dest, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, mode);
rprintf(FERROR,"open %s: %s\n",
dest,strerror(errno));
close(ifd);
rprintf(FERROR,"open %s: %s\n",
dest,strerror(errno));
close(ifd);