From e92030239abb4038d4f915d47021d6c037239309 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Wed, 19 Apr 2017 07:44:48 +0200 Subject: Assume that accept4 is always available and works Simplify the Linux accept4 implementation based on the assumption that it is available in some way. __ASSUME_ACCEPT4_SOCKETCALL was previously unused, so remove it. For ia64, the accept4 system call (and socket call) were backported in kernel version 3.2.18. Reflect this in the installation instructions. --- nscd/connections.c | 50 ++------------------------------------------------ 1 file changed, 2 insertions(+), 48 deletions(-) (limited to 'nscd') diff --git a/nscd/connections.c b/nscd/connections.c index a5ca57a..cc1ed72 100644 --- a/nscd/connections.c +++ b/nscd/connections.c @@ -257,10 +257,6 @@ int inotify_fd = -1; static int nl_status_fd = -1; #endif -#ifndef __ASSUME_ACCEPT4 -static int have_accept4; -#endif - /* Number of times clients had to wait. */ unsigned long int client_queued; @@ -1650,16 +1646,6 @@ nscd_run_worker (void *p) /* We are done with the list. */ pthread_mutex_unlock (&readylist_lock); -#ifndef __ASSUME_ACCEPT4 - if (have_accept4 < 0) - { - /* We do not want to block on a short read or so. */ - int fl = fcntl (fd, F_GETFL); - if (fl == -1 || fcntl (fd, F_SETFL, fl | O_NONBLOCK) == -1) - goto close_and_out; - } -#endif - /* Now read the request. */ request_header req; if (__builtin_expect (TEMP_FAILURE_RETRY (read (fd, &req, sizeof (req))) @@ -2099,24 +2085,8 @@ main_loop_poll (void) if (conns[0].revents != 0) { /* We have a new incoming connection. Accept the connection. */ - int fd; - -#ifndef __ASSUME_ACCEPT4 - fd = -1; - if (have_accept4 >= 0) -#endif - { - fd = TEMP_FAILURE_RETRY (accept4 (sock, NULL, NULL, + int fd = TEMP_FAILURE_RETRY (accept4 (sock, NULL, NULL, SOCK_NONBLOCK)); -#ifndef __ASSUME_ACCEPT4 - if (have_accept4 == 0) - have_accept4 = fd != -1 || errno != ENOSYS ? 1 : -1; -#endif - } -#ifndef __ASSUME_ACCEPT4 - if (have_accept4 < 0) - fd = TEMP_FAILURE_RETRY (accept (sock, NULL, NULL)); -#endif /* Use the descriptor if we have not reached the limit. */ if (fd >= 0) @@ -2284,24 +2254,8 @@ main_loop_epoll (int efd) if (revs[cnt].data.fd == sock) { /* A new connection. */ - int fd; - -# ifndef __ASSUME_ACCEPT4 - fd = -1; - if (have_accept4 >= 0) -# endif - { - fd = TEMP_FAILURE_RETRY (accept4 (sock, NULL, NULL, + int fd = TEMP_FAILURE_RETRY (accept4 (sock, NULL, NULL, SOCK_NONBLOCK)); -# ifndef __ASSUME_ACCEPT4 - if (have_accept4 == 0) - have_accept4 = fd != -1 || errno != ENOSYS ? 1 : -1; -# endif - } -# ifndef __ASSUME_ACCEPT4 - if (have_accept4 < 0) - fd = TEMP_FAILURE_RETRY (accept (sock, NULL, NULL)); -# endif /* Use the descriptor if we have not reached the limit. */ if (fd >= 0) -- cgit v1.1