If accept4 is absent, fall back to accept.

This commit is contained in:
Nick Mathewson 2012-02-21 20:39:17 -05:00
parent a6492cb744
commit 74d32dd493

View File

@ -2425,10 +2425,13 @@ evutil_socket_t
evutil_accept4(evutil_socket_t sockfd, struct sockaddr *addr, evutil_accept4(evutil_socket_t sockfd, struct sockaddr *addr,
socklen_t *addrlen, int flags) socklen_t *addrlen, int flags)
{ {
evutil_socket_t result;
#if defined(_EVENT_HAVE_ACCEPT4) && defined(SOCK_CLOEXEC) && defined(SOCK_NONBLOCK) #if defined(_EVENT_HAVE_ACCEPT4) && defined(SOCK_CLOEXEC) && defined(SOCK_NONBLOCK)
return accept4(sockfd, addr, addrlen, flags); result = accept4(sockfd, addr, addrlen, flags);
#else if (result >= 0 || errno != EINVAL)
evutil_socket_t result = accept(sockfd, addr, addrlen); return result;
#endif
result = accept(sockfd, addr, addrlen);
if (result < 0) if (result < 0)
return result; return result;
@ -2445,7 +2448,6 @@ evutil_accept4(evutil_socket_t sockfd, struct sockaddr *addr,
} }
} }
return result; return result;
#endif
} }
/* Internal function: Set fd[0] and fd[1] to a pair of fds such that writes on /* Internal function: Set fd[0] and fd[1] to a pair of fds such that writes on