summaryrefslogtreecommitdiff
path: root/src/config.h
diff options
context:
space:
mode:
authorOran Agra <oran@redislabs.com>2021-07-05 10:34:20 +0300
committerGitHub <noreply@github.com>2021-07-05 10:34:20 +0300
commit5a3de81925130792f78c35e9e4d0204213a3a41e (patch)
tree34e46fe7b782a64f0ed7e0f04e59e6a419020714 /src/config.h
parentec582cc7ad0706e252bc905822226e49f4c4d0e4 (diff)
downloadredis-5a3de81925130792f78c35e9e4d0204213a3a41e.tar.gz
Use accept4 on linux instead of fcntl to make a client socket non-blocking (#9177)
This reduces system calls on linux when a new connection is made / accepted. Changes: * Add the SOCK_CLOEXEC option to the accept4() call This ensure that a fork/exec call does not leak a file descriptor. * Move anetCloexec and connNonBlock info anetGenericAccept * Moving connNonBlock from accept handlers to anetGenericAccept Moving connNonBlock from createClient, is safe because createClient is used in the following ways: 1. without a connection (fake client) 2. on an accepted connection (see above) 3. creating the master client by using connConnect (see below) The third case, can either use anetTcpNonBlockConnect, or connTLSConnect which is by default non-blocking. Co-authored-by: Rajiv Kurian <geetasen@gmail.com> Co-authored-by: Oran Agra <oran@redislabs.com> Co-authored-by: Yoav Steinberg <yoav@redislabs.com>
Diffstat (limited to 'src/config.h')
-rw-r--r--src/config.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/config.h b/src/config.h
index 56c1ab6ae..af5209f89 100644
--- a/src/config.h
+++ b/src/config.h
@@ -78,6 +78,11 @@
#define HAVE_EPOLL 1
#endif
+/* Test for accept4() */
+#ifdef __linux__
+#define HAVE_ACCEPT4 1
+#endif
+
#if (defined(__APPLE__) && defined(MAC_OS_X_VERSION_10_6)) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined (__NetBSD__)
#define HAVE_KQUEUE 1
#endif