changeset 14634:a65006d95d53

fd_set_nonblock() API changed to i_fatal() on failure. Pretty much none of its users were checking if it failed, and there's really no good reason for it to fail anyway.
author Timo Sirainen <tss@iki.fi>
date Sun, 24 Jun 2012 19:35:11 +0300
parents fa1898ef59c4
children 45952eee7ad4
files src/lib/fd-set-nonblock.c src/lib/fd-set-nonblock.h src/lib/network.c
diffstat 3 files changed, 7 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/fd-set-nonblock.c	Sun Jun 24 19:13:58 2012 +0300
+++ b/src/lib/fd-set-nonblock.c	Sun Jun 24 19:35:11 2012 +0300
@@ -5,24 +5,19 @@
 
 #include <fcntl.h>
 
-int fd_set_nonblock(int fd, bool nonblock)
+void fd_set_nonblock(int fd, bool nonblock)
 {
 	int flags;
 
 	flags = fcntl(fd, F_GETFL, 0);
-	if (flags < 0) {
-		i_error("fcntl(%d, F_GETFL) failed: %m", fd);
-		return -1;
-	}
+	if (flags < 0)
+		i_fatal("fcntl(%d, F_GETFL) failed: %m", fd);
 
 	if (nonblock)
 		flags |= O_NONBLOCK;
 	else
 		flags &= ~O_NONBLOCK;
 
-	if (fcntl(fd, F_SETFL, flags) < 0) {
-		i_error("fcntl(%d, F_SETFL) failed: %m", fd);
-		return -1;
-	}
-	return 0;
+	if (fcntl(fd, F_SETFL, flags) < 0)
+		i_fatal("fcntl(%d, F_SETFL) failed: %m", fd);
 }
--- a/src/lib/fd-set-nonblock.h	Sun Jun 24 19:13:58 2012 +0300
+++ b/src/lib/fd-set-nonblock.h	Sun Jun 24 19:35:11 2012 +0300
@@ -2,6 +2,6 @@
 #define FD_SET_NONBLOCK_H
 
 /* Set file descriptor to blocking/nonblocking state */
-int fd_set_nonblock(int fd, bool nonblock);
+void fd_set_nonblock(int fd, bool nonblock);
 
 #endif
--- a/src/lib/network.c	Sun Jun 24 19:13:58 2012 +0300
+++ b/src/lib/network.c	Sun Jun 24 19:35:11 2012 +0300
@@ -334,8 +334,7 @@
 
 void net_set_nonblock(int fd, bool nonblock)
 {
-	if (fd_set_nonblock(fd, nonblock) < 0)
-		i_fatal("fd_set_nonblock(%d) failed: %m", fd);
+	fd_set_nonblock(fd, nonblock);
 }
 
 int net_set_cork(int fd ATTR_UNUSED, bool cork ATTR_UNUSED)