]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Handle EWOULDBLOCK as EAGAIN if they happen to be different.
authorNick Mathewson <nickm@torproject.org>
Sat, 12 Jan 2013 00:27:45 +0000 (16:27 -0800)
committerNick Mathewson <nickm@torproject.org>
Sat, 12 Jan 2013 00:36:54 +0000 (16:36 -0800)
Fixes bug 7935.  Reported by 'oftc_must_be_destroyed'.

changes/bug7935 [new file with mode: 0644]
src/common/compat.h
src/ext/eventdns.c

diff --git a/changes/bug7935 b/changes/bug7935
new file mode 100644 (file)
index 0000000..ef91001
--- /dev/null
@@ -0,0 +1,4 @@
+  o Minor features (portability):
+    - Work correctly on unix systems where EAGAIN and EWOULDBLOCK are
+      separate error codes--or at least, don't break for that reason.
+      Fixes bug 7935. Reported by "oftc_must_be_destroyed".
index 9c544fa3097d613ea6dfed5a0024d7dfc1945130..f597c122c21a10362f189890ff2d258d0f6d57bb 100644 (file)
@@ -53,6 +53,7 @@
 #endif
 
 #include <stdio.h>
+#include <errno.h>
 
 #if defined (WINCE)
 #include <fcntl.h>
@@ -538,10 +539,14 @@ int tor_socket_errno(tor_socket_t sock);
 const char *tor_socket_strerror(int e);
 #else
 #define SOCK_ERRNO(e) e
+#if EAGAIN == EWOULDBLOCK
 #define ERRNO_IS_EAGAIN(e)           ((e) == EAGAIN)
+#else
+#define ERRNO_IS_EAGAIN(e)           ((e) == EAGAIN || (e) == EWOULDBLOCK)
+#endif
 #define ERRNO_IS_EINPROGRESS(e)      ((e) == EINPROGRESS)
 #define ERRNO_IS_CONN_EINPROGRESS(e) ((e) == EINPROGRESS)
-#define ERRNO_IS_ACCEPT_EAGAIN(e)    ((e) == EAGAIN || (e) == ECONNABORTED)
+#define ERRNO_IS_ACCEPT_EAGAIN(e)    (ERRNO_IS_EAGAIN(e) || (e) == ECONNABORTED)
 #define ERRNO_IS_ACCEPT_RESOURCE_LIMIT(e) \
   ((e) == EMFILE || (e) == ENFILE || (e) == ENOBUFS || (e) == ENOMEM)
 #define ERRNO_IS_EADDRINUSE(e)       ((e) == EADDRINUSE)
index 7e99f5562634338db97a89148a1ce2a9c1ffd339..b1f586b2fb4a3c8d7dd33beffc9a7a359441cd18 100644 (file)
@@ -368,7 +368,11 @@ error_is_eagain(int err)
 #define CLOSE_SOCKET(x) closesocket(x)
 #else
 #define last_error(sock) (errno)
+#if EAGAIN != EWOULDBLOCK
+#define error_is_eagain(err) ((err) == EAGAIN || (err) == EWOULDBLOCK)
+#else
 #define error_is_eagain(err) ((err) == EAGAIN)
+#endif
 #define CLOSE_SOCKET(x) close(x)
 #endif