]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: move fd_set_nonblock() to fd-util.[ch]
authorJosef 'Jeff' Sipek <jeff.sipek@dovecot.fi>
Wed, 4 Oct 2017 12:42:56 +0000 (08:42 -0400)
committerJosef 'Jeff' Sipek <jeff.sipek@dovecot.fi>
Thu, 5 Oct 2017 19:41:10 +0000 (15:41 -0400)
src/lib/Makefile.am
src/lib/fd-set-nonblock.c [deleted file]
src/lib/fd-set-nonblock.h [deleted file]
src/lib/fd-util.c
src/lib/fd-util.h

index 54e47da074709646e08ae44119fd26ef82dbb089..31577c078ae05002cb83ac5c28c204cee788599c 100644 (file)
@@ -29,7 +29,6 @@ liblib_la_SOURCES = \
        env-util.c \
        execv-const.c \
        failures.c \
-       fd-set-nonblock.c \
        fd-util.c \
        fdatasync-path.c \
        fdpass.c \
@@ -182,7 +181,6 @@ headers = \
        env-util.h \
        execv-const.h \
        failures.h \
-       fd-set-nonblock.h \
        fd-util.h \
        fdatasync-path.h \
        fdpass.h \
diff --git a/src/lib/fd-set-nonblock.c b/src/lib/fd-set-nonblock.c
deleted file mode 100644 (file)
index 4b76cd7..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright (c) 1999-2017 Dovecot authors, see the included COPYING file */
-
-#include "lib.h"
-
-#include <fcntl.h>
-
-void fd_set_nonblock(int fd, bool nonblock)
-{
-       int flags;
-
-       flags = fcntl(fd, F_GETFL, 0);
-       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_fatal("fcntl(%d, F_SETFL) failed: %m", fd);
-}
diff --git a/src/lib/fd-set-nonblock.h b/src/lib/fd-set-nonblock.h
deleted file mode 100644 (file)
index dd25628..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef FD_SET_NONBLOCK_H
-#define FD_SET_NONBLOCK_H
-
-/* Set file descriptor to blocking/nonblocking state */
-void fd_set_nonblock(int fd, bool nonblock);
-
-#endif
index 6f5db11362fc432208a898a2b4a233379c124be7..80c3c95b7860531ed9348343a16d45d727082279 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2002-2017 Dovecot authors, see the included COPYING file */
+/* Copyright (c) 1999-2017 Dovecot authors, see the included COPYING file */
 
 #include "lib.h"
 #include "net.h"
@@ -94,3 +94,20 @@ void fd_debug_verify_leaks(int first_fd, int last_fd)
        if (leaks)
                i_fatal("fd leak found");
 }
+
+void fd_set_nonblock(int fd, bool nonblock)
+{
+       int flags;
+
+       flags = fcntl(fd, F_GETFL, 0);
+       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_fatal("fcntl(%d, F_SETFL) failed: %m", fd);
+}
index d0a12555110ca89587d426cd42a2494b5513f5b7..bf81f69d797fe583d40f45e2674f5f35c95e7bed 100644 (file)
@@ -1,12 +1,13 @@
 #ifndef FD_UTIL_H
 #define FD_UTIL_H
 
-#include "fd-set-nonblock.h"
-
 /* Change close-on-exec flag of fd. */
 void fd_close_on_exec(int fd, bool set);
 
 /* Verify that fds in given range don't exist. */
 void fd_debug_verify_leaks(int first_fd, int last_fd);
 
+/* Set file descriptor to blocking/nonblocking state */
+void fd_set_nonblock(int fd, bool nonblock);
+
 #endif