summaryrefslogtreecommitdiffstats
path: root/lib/network.c
diff options
context:
space:
mode:
authorajs <ajs>2005-02-16 01:45:37 +0100
committerajs <ajs>2005-02-16 01:45:37 +0100
commita269d613fe0536a01eb86367a545e337e51d1309 (patch)
tree21e648eaac2a1569af79dcbc75a962481b6cbc75 /lib/network.c
parentAdjust size complexity estimates. Still not quite right, but closer. (diff)
downloadfrr-a269d613fe0536a01eb86367a545e337e51d1309.tar.xz
frr-a269d613fe0536a01eb86367a545e337e51d1309.zip
2005-02-15 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* network.h: Declare new function set_nonblocking. Indicate that readn and writen are deprecated. * network.c: (set_nonblocking) New function to make a file descriptor non-blocking, since it seems silly to have fcntl calls sprinkled throughout the code.
Diffstat (limited to 'lib/network.c')
-rw-r--r--lib/network.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/network.c b/lib/network.c
index e1f733cf2..3b296720d 100644
--- a/lib/network.c
+++ b/lib/network.c
@@ -21,6 +21,8 @@
*/
#include <zebra.h>
+#include "log.h"
+#include "network.h"
/* Read nbytes from fd and store into ptr. */
int
@@ -69,3 +71,15 @@ writen(int fd, const u_char *ptr, int nbytes)
}
return nbytes - nleft;
}
+
+int
+set_nonblocking(int fd)
+{
+ if (fcntl(fd, F_SETFL, (fcntl(fd, F_GETFL) | O_NONBLOCK)) < 0)
+ {
+ zlog_warn("fcntl failed setting fd %d non-blocking: %s",
+ fd, safe_strerror(errno));
+ return -1;
+ }
+ return 0;
+}