diff options
-rw-r--r-- | changes/bug5762 | 4 | ||||
-rw-r--r-- | src/common/compat.c | 15 |
2 files changed, 12 insertions, 7 deletions
diff --git a/changes/bug5762 b/changes/bug5762 new file mode 100644 index 0000000000..a91f4dfedf --- /dev/null +++ b/changes/bug5762 @@ -0,0 +1,4 @@ + o Minor bugfixes: + - Work correctly on Linux systems with accept4 support advertised in + their headers, but without accept4 support in the kernel. Fix + by murb. Fixes bug 5762; bugfix on 0.2.3.1-alpha. diff --git a/src/common/compat.c b/src/common/compat.c index fbb37ce031..57fc021f35 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -129,7 +129,7 @@ tor_open_cloexec(const char *path, int flags, unsigned mode) if (fd >= 0) return fd; /* If we got an error, see if it is EINVAL. EINVAL might indicate that, - * event though we were built on a system with O_CLOEXEC support, we + * even though we were built on a system with O_CLOEXEC support, we * are running on one without. */ if (errno != EINVAL) return -1; @@ -980,7 +980,7 @@ tor_open_socket(int domain, int type, int protocol) if (SOCKET_OK(s)) goto socket_ok; /* If we got an error, see if it is EINVAL. EINVAL might indicate that, - * event though we were built on a system with SOCK_CLOEXEC support, we + * even though we were built on a system with SOCK_CLOEXEC support, we * are running on one without. */ if (errno != EINVAL) return s; @@ -1013,10 +1013,11 @@ tor_accept_socket(tor_socket_t sockfd, struct sockaddr *addr, socklen_t *len) s = accept4(sockfd, addr, len, SOCK_CLOEXEC); if (SOCKET_OK(s)) goto socket_ok; - /* If we got an error, see if it is EINVAL. EINVAL might indicate that, - * event though we were built on a system with accept4 support, we - * are running on one without. */ - if (errno != EINVAL) + /* If we got an error, see if it is ENOSYS. ENOSYS indicates that, + * even though we were built on a system with accept4 support, we + * are running on one without. Also, check for EINVAL, which indicates that + * we are missing SOCK_CLOEXEC support. */ + if (errno != EINVAL && errno != ENOSYS) return s; #endif @@ -1091,7 +1092,7 @@ tor_socketpair(int family, int type, int protocol, tor_socket_t fd[2]) if (r == 0) goto sockets_ok; /* If we got an error, see if it is EINVAL. EINVAL might indicate that, - * event though we were built on a system with SOCK_CLOEXEC support, we + * even though we were built on a system with SOCK_CLOEXEC support, we * are running on one without. */ if (errno != EINVAL) return -errno; |