summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2011-08-14 14:23:16 +0200
committerMartin Sustrik <sustrik@250bpm.com>2011-08-14 14:23:16 +0200
commit9196c482564e74e310b48e1add9f5425efb07ec0 (patch)
tree37098c56dc77ced3e0a705c773be33ea566a17ee
parent938009853461267af43908614266b9ef33f825ff (diff)
select version zmq_poll reports invalid FDs
Till now, passing invalid file descriptor to zmq_poll() caused asseration. Now it returns error. Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
-rw-r--r--src/zmq.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/zmq.cpp b/src/zmq.cpp
index 39d5404..5fcdd21 100644
--- a/src/zmq.cpp
+++ b/src/zmq.cpp
@@ -592,12 +592,19 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
memcpy (&errset, &pollset_err, sizeof (fd_set));
#if defined ZMQ_HAVE_WINDOWS
int rc = select (0, &inset, &outset, &errset, ptimeout);
- wsa_assert (rc != SOCKET_ERROR);
+ if (unlikely (rc == SOCKET_ERROR)) {
+ wsa_error_to_errno ();
+ if (errno == ENOTSOCK)
+ return -1;
+ wsa_assert (false);
+ }
#else
int rc = select (maxfd + 1, &inset, &outset, &errset, ptimeout);
- if (rc == -1 && errno == EINTR)
- return -1;
- errno_assert (rc >= 0);
+ if (unlikely (rc == -1) {
+ if (errno == EINTR || errno == EBADF)
+ return -1;
+ errno_assert (false);
+ }
#endif
break;
}