]> granicus.if.org Git - libevent/commitdiff
When EWOULDBLOCK is not EAGAIN, treat it as equivalent to it
authorNick Mathewson <nickm@torproject.org>
Sat, 12 Jan 2013 00:37:34 +0000 (16:37 -0800)
committerNick Mathewson <nickm@torproject.org>
Sat, 12 Jan 2013 00:37:34 +0000 (16:37 -0800)
Acording to http://stackoverflow.com/questions/7003234/which-systems-define-eagain-and-ewouldblock-as-different-values
there are some older unixes that distinguish these error.s

event.c
util-internal.h

diff --git a/event.c b/event.c
index ce2828fe18eefd458d3aed71efadf4b0dfeced2d..fb20f696eeeeb562b8369c79fedec7fce65aae17 100644 (file)
--- a/event.c
+++ b/event.c
@@ -2157,7 +2157,7 @@ evthread_notify_base_default(struct event_base *base)
 #else
        r = write(base->th_notify_fd[1], buf, 1);
 #endif
-       return (r < 0 && errno != EAGAIN) ? -1 : 0;
+       return (r < 0 && ! EVUTIL_ERR_IS_EAGAIN(errno)) ? -1 : 0;
 }
 
 #ifdef EVENT__HAVE_EVENTFD
index fa29f271441f09089a94e9a8688cca4c0b4cc07c..f52ae3f4f4ee5037b7e33968cdb0d2a66cd236fe 100644 (file)
@@ -79,15 +79,23 @@ extern "C" {
 
 #ifndef _WIN32
 
+#if EAGAIN == EWOULDBLOCK
+#define EVUTIL_ERR_IS_EAGAIN(e) \
+       ((e) == EAGAIN)
+#else
+#define EVUTIL_ERR_IS_EAGAIN(e) \
+       ((e) == EAGAIN || (e) == EWOULDBLOCK)
+#endif
+
 /* True iff e is an error that means a read/write operation can be retried. */
 #define EVUTIL_ERR_RW_RETRIABLE(e)                             \
-       ((e) == EINTR || (e) == EAGAIN)
+       ((e) == EINTR || EVUTIL_ERR_IS_EAGAIN(e))
 /* True iff e is an error that means an connect can be retried. */
 #define EVUTIL_ERR_CONNECT_RETRIABLE(e)                        \
        ((e) == EINTR || (e) == EINPROGRESS)
 /* True iff e is an error that means a accept can be retried. */
 #define EVUTIL_ERR_ACCEPT_RETRIABLE(e)                 \
-       ((e) == EINTR || (e) == EAGAIN || (e) == ECONNABORTED)
+       ((e) == EINTR || EVUTIL_ERR_IS_EAGAIN(e) || (e) == ECONNABORTED)
 
 /* True iff e is an error that means the connection was refused */
 #define EVUTIL_ERR_CONNECT_REFUSED(e)                                  \