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
{
int n, ret=0;
+ no_flush_read++;
io_flush();
+ no_flush_read--;
while (ret == 0) {
fd_set fds;
continue;
}
+ no_flush_read++;
io_flush();
+ no_flush_read--;
ret = read_unbuffered(fd,buffer + total,N-total);
total += ret;
fd_set w_fds, r_fds;
int fd_count, count;
struct timeval tv;
- int reading;
+ int reading=0;
int blocked=0;
no_flush++;
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 (!get_tmpname(fnametmp,fname)) {
if (buf) unmap_file(buf);
- close(fd1);
+ if (fd1 != -1) close(fd1);
continue;
}
rprintf(FERROR,"mktemp %s failed\n",fnametmp);
receive_data(f_in,buf,-1,NULL,file->length);
if (buf) unmap_file(buf);
- close(fd1);
+ if (fd1 != -1) close(fd1);
continue;
}
rprintf(FERROR,"open %s : %s\n",fnametmp,strerror(errno));
receive_data(f_in,buf,-1,NULL,file->length);
if (buf) unmap_file(buf);
- close(fd1);
+ if (fd1 != -1) close(fd1);
continue;
}
{
int i;
- if (fork())
+ if (fork()) {
_exit(0);
+ }
/* 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
}
ofd = do_open(dest, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, mode);
- if (ofd < 0) {
+ if (ofd == -1) {
rprintf(FERROR,"open %s: %s\n",
dest,strerror(errno));
close(ifd);