diff src/lib/network.c @ 3621:3ae2df67459c HEAD

Added fd_set_nonblock() and changed net_set_nonblock() to use it.
author Timo Sirainen <tss@iki.fi>
date Sun, 25 Sep 2005 14:12:24 +0300
parents 51d30414b8bd
children 771cd6776d4b
line wrap: on
line diff
--- a/src/lib/network.c	Sun Sep 25 14:07:32 2005 +0300
+++ b/src/lib/network.c	Sun Sep 25 14:12:24 2005 +0300
@@ -1,6 +1,7 @@
-/* Copyright (c) 1999-2003 Timo Sirainen */
+/* Copyright (c) 1999-2005 Timo Sirainen */
 
 #include "lib.h"
+#include "fd-set-nonblock.h"
 #include "network.h"
 
 #include <unistd.h>
@@ -203,23 +204,10 @@
 }
 
 /* Set socket blocking/nonblocking */
-void net_set_nonblock(int fd __attr_unused__, int nonblock __attr_unused__)
+void net_set_nonblock(int fd, int nonblock)
 {
-#ifdef HAVE_FCNTL
-	int flags;
-
-	flags = fcntl(fd, F_GETFL, 0);
-	if (flags == -1)
-		i_fatal("net_set_nonblock() failed: %m");
-
-	if (nonblock)
-		flags |= O_NONBLOCK;
-	else
-		flags &= ~O_NONBLOCK;
-
-	if (fcntl(fd, F_SETFL, flags) < 0)
-		i_fatal("net_set_nonblock() failed: %m");
-#endif
+	if (fd_set_nonblock(fd, nonblock) < 0)
+		i_fatal("fd_set_nonblock(%d) failed: %m", fd);
 }
 
 int net_set_cork(int fd __attr_unused__, int cork __attr_unused__)