[dovecot-cvs] dovecot/src/lib network.c,1.20,1.21

cras at procontrol.fi cras at procontrol.fi
Sun Nov 9 22:20:39 EET 2003


Update of /home/cvs/dovecot/src/lib
In directory danu:/tmp/cvs-serv1768

Modified Files:
	network.c 
Log Message:
net_set_nonblock(): don't replace flags in fd, change the existing ones



Index: network.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/network.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- network.c	26 Aug 2003 21:18:16 -0000	1.20
+++ network.c	9 Nov 2003 20:20:36 -0000	1.21
@@ -194,7 +194,18 @@
 void net_set_nonblock(int fd __attr_unused__, int nonblock __attr_unused__)
 {
 #ifdef HAVE_FCNTL
-	if (fcntl(fd, F_SETFL, nonblock ? O_NONBLOCK : 0) < 0)
+	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
 }



More information about the dovecot-cvs mailing list