mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-18 16:54:42 -04:00
Correctly handle running on a system where accept4 doesn't work.
Previously, we treated EINVAL as the only errno that indicated a broken accept4. But EINVAL only appears when one of the SOCK_* options isn't supported. If the accept4 syscall itself isn't there, we'll get an ENOSYS. Reported by Azat Khuzhin.
This commit is contained in:
parent
a163026099
commit
9fbfe9b948
8
evutil.c
8
evutil.c
@ -2382,8 +2382,14 @@ evutil_accept4_(evutil_socket_t sockfd, struct sockaddr *addr,
|
||||
evutil_socket_t result;
|
||||
#if defined(EVENT__HAVE_ACCEPT4) && defined(SOCK_CLOEXEC) && defined(SOCK_NONBLOCK)
|
||||
result = accept4(sockfd, addr, addrlen, flags);
|
||||
if (result >= 0 || errno != EINVAL)
|
||||
if (result >= 0 || (errno != EINVAL && errno != ENOSYS)) {
|
||||
/* A nonnegative result means that we succeeded, so return.
|
||||
* Failing with EINVAL means that an option wasn't supported,
|
||||
* and failing with ENOSYS means that the syscall wasn't
|
||||
* there: in those cases we want to fall back. Otherwise, we
|
||||
* got a real error, and we should return. */
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
result = accept(sockfd, addr, addrlen);
|
||||
if (result < 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user