summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-01-13 21:43:53 -0500
committerNick Mathewson <nickm@torproject.org>2013-01-13 21:43:53 -0500
commitdab25eb37dd7d5245a03a5380ba5f80c64e4ac3d (patch)
treee8785e1ce22eed6e376e0e8bcc400bf7f0f02516
parentdffc8e359bcfeb00813a3afde6aa2328f6a6a476 (diff)
parenta5ee3834bf060c8a238be84ea7287bdfa8303a27 (diff)
downloadtor-dab25eb37dd7d5245a03a5380ba5f80c64e4ac3d.tar.gz
tor-dab25eb37dd7d5245a03a5380ba5f80c64e4ac3d.zip
Merge branch 'bug7935'
-rw-r--r--changes/bug79354
-rw-r--r--src/common/compat.h7
-rw-r--r--src/ext/eventdns.c4
3 files changed, 14 insertions, 1 deletions
diff --git a/changes/bug7935 b/changes/bug7935
new file mode 100644
index 0000000000..ef910012c7
--- /dev/null
+++ b/changes/bug7935
@@ -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".
diff --git a/src/common/compat.h b/src/common/compat.h
index 9c544fa309..f597c122c2 100644
--- a/src/common/compat.h
+++ b/src/common/compat.h
@@ -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)
diff --git a/src/ext/eventdns.c b/src/ext/eventdns.c
index 7e99f55626..b1f586b2fb 100644
--- a/src/ext/eventdns.c
+++ b/src/ext/eventdns.c
@@ -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