]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
fd_set_nonblock() API changed to i_fatal() on failure.
authorTimo Sirainen <tss@iki.fi>
Sun, 24 Jun 2012 16:35:11 +0000 (19:35 +0300)
committerTimo Sirainen <tss@iki.fi>
Sun, 24 Jun 2012 16:35:11 +0000 (19:35 +0300)
Pretty much none of its users were checking if it failed, and there's really
no good reason for it to fail anyway.

src/lib/fd-set-nonblock.c
src/lib/fd-set-nonblock.h
src/lib/network.c

index d19df95cf3f88f1fc45737e7a9128236e0041ea3..f853507789103baf26bc4e804b5e175b84c4fa8b 100644 (file)
@@ -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);
 }
index 44a8fbc45a01796fb8c512fc24cd4c364a9d77de..dd25628fa63d50731f7ebcd6698bbc963de47b20 100644 (file)
@@ -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
index 8b2198aaa041281c8804863dbdf161a104b1b4bc..5946a3b3db4741a8b4788bf35389e4fb569537f7 100644 (file)
@@ -334,8 +334,7 @@ void net_disconnect(int fd)
 
 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)