aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-05-04 13:17:20 -0400
committerNick Mathewson <nickm@torproject.org>2012-05-04 13:18:14 -0400
commita1538d607d54065c2d74c8fa695d1c0b5e33c64f (patch)
treeb4c6ab6790cbf17a6702244bb939f53839a3f935 /src
parentc9afd6f9c5a3cf73340e528818570b4ba5cdf6b2 (diff)
downloadtor-a1538d607d54065c2d74c8fa695d1c0b5e33c64f.tar
tor-a1538d607d54065c2d74c8fa695d1c0b5e33c64f.tar.gz
Fix bug 5762: detect missing accept4 that gives ENOSYS
We had been checking for EINVAL, but that means that SOCK_* isn't supported, not that the syscall itself is missing. Bugfix on 0.2.3.1-alpha, which started to use accept4.
Diffstat (limited to 'src')
-rw-r--r--src/common/compat.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/common/compat.c b/src/common/compat.c
index fbb37ce03..1a03f5efc 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -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,
+ /* If we got an error, see if it is ENOSYS. ENOSYS indicates that,
* event though we were built on a system with accept4 support, we
- * are running on one without. */
- if (errno != EINVAL)
+ * 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