dovecot-2.2: fd_set_nonblock() API changed to i_fatal() on failure.

dovecot at dovecot.org dovecot at dovecot.org
Sun Jun 24 19:35:23 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/a65006d95d53
changeset: 14634:a65006d95d53
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Jun 24 19:35:11 2012 +0300
description:
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.

diffstat:

 src/lib/fd-set-nonblock.c |  15 +++++----------
 src/lib/fd-set-nonblock.h |   2 +-
 src/lib/network.c         |   3 +--
 3 files changed, 7 insertions(+), 13 deletions(-)

diffs (57 lines):

diff -r fa1898ef59c4 -r a65006d95d53 src/lib/fd-set-nonblock.c
--- 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);
 }
diff -r fa1898ef59c4 -r a65006d95d53 src/lib/fd-set-nonblock.h
--- 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
diff -r fa1898ef59c4 -r a65006d95d53 src/lib/network.c
--- 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)


More information about the dovecot-cvs mailing list