From 62faf7d37bd8b6be6657b1e3b61f92eac5b84653 Mon Sep 17 00:00:00 2001 From: Krishnan Parthasarathi Date: Thu, 11 Oct 2018 15:16:41 +0530 Subject: socket: use accept4/paccept for nonblocking socket This reduces the no. of syscalls on Linux systems from 2, accept(2) and fcntl(2) for setting O_NONBLOCK, to a single accept4(2). On NetBSD, we have paccept(2) that does the same, if we leave signal masking aside. Added sys_accept which accepts an extra flags argument than accept(2). This would opportunistically use accept4/paccept as available. It would fallback to accept(2) and fcntl(2) otherwise. While at this, the patch sets FD_CLOEXEC flag on the accepted socket fd. BUG: 1236272 Change-Id: I41e43fd3e36d6dabb07e578a1cea7f45b7b4e37f fixes: bz#1236272 Signed-off-by: Krishnan Parthasarathi --- configure.ac | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 9925ad918b9..afba73e18cf 100644 --- a/configure.ac +++ b/configure.ac @@ -1140,6 +1140,16 @@ if test "x${ac_cv_have_decl_SEEK_HOLE}" = "xyes"; then fi CFLAGS=${OLD_CFLAGS} +AC_CHECK_FUNC([accept4], [have_accept4=yes]) +if test "x${have_accept4}" = "xyes"; then + AC_DEFINE(HAVE_ACCEPT4, 1, [define if accept4 exists]) +fi + +AC_CHECK_FUNC([paccept], [have_paccept=yes]) +if test "x${have_paccept}" = "xyes"; then +AC_DEFINE(HAVE_PACCEPT, 1, [define if paccept exists]) +fi + # Check the distribution where you are compiling glusterfs on GF_DISTRIBUTION= -- cgit