summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1998-06-18 09:32:45 +0000
committerAndrew Tridgell <tridge@samba.org>1998-06-18 09:32:45 +0000
commita5343e765b5652d8e097ea9c398693e60a2d64d2 (patch)
tree243f5cc9e3c42b088d2b0268e5a61f32cc44705a /util.c
parent704f908eae2008475e3aba005331e69c98c52234 (diff)
downloadrsync-a5343e765b5652d8e097ea9c398693e60a2d64d2.tar.gz
put set_nonblocking() code back in.
Diffstat (limited to 'util.c')
-rw-r--r--util.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/util.c b/util.c
index b80d5161..639a4a4f 100644
--- a/util.c
+++ b/util.c
@@ -24,15 +24,33 @@
*/
#include "rsync.h"
-int num_waiting(int fd)
+/****************************************************************************
+Set a fd into nonblocking mode. Uses POSIX O_NONBLOCK if available,
+else
+if SYSV use O_NDELAY
+if BSD use FNDELAY
+****************************************************************************/
+int set_nonblocking(int fd)
{
- int len=0;
- ioctl(fd,FIONREAD,&len);
- return(len);
+ int val;
+#ifdef O_NONBLOCK
+#define FLAG_TO_SET O_NONBLOCK
+#else
+#ifdef SYSV
+#define FLAG_TO_SET O_NDELAY
+#else /* BSD */
+#define FLAG_TO_SET FNDELAY
+#endif
+#endif
+
+ if((val = fcntl(fd, F_GETFL, 0)) == -1)
+ return -1;
+ val |= FLAG_TO_SET;
+ return fcntl( fd, F_SETFL, val);
+#undef FLAG_TO_SET
}
-
/* this is taken from CVS */
int piped_child(char **command,int *f_in,int *f_out)
{
@@ -206,7 +224,7 @@ int create_directory_path(char *fname)
derived from GNU C's cccp.c.
*/
-int full_write(int desc, char *ptr, int len)
+static int full_write(int desc, char *ptr, int len)
{
int total_written;