]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fix bug 5762: detect missing accept4 that gives ENOSYS
authorNick Mathewson <nickm@torproject.org>
Fri, 4 May 2012 17:17:20 +0000 (13:17 -0400)
committerNick Mathewson <nickm@torproject.org>
Fri, 4 May 2012 17:18:14 +0000 (13:18 -0400)
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.

changes/bug5762 [new file with mode: 0644]
src/common/compat.c

diff --git a/changes/bug5762 b/changes/bug5762
new file mode 100644 (file)
index 0000000..a91f4df
--- /dev/null
@@ -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.
index fbb37ce031258d1b45632b9b54b6f698f271283f..1a03f5efc7fe530d661e0b3089bd61ac031261fc 100644 (file)
@@ -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