0
0
mirror of https://github.com/zeromq/libzmq.git synced 2024-12-29 00:32:34 +08:00

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>
This commit is contained in:
Martin Sustrik 2011-08-14 14:23:16 +02:00
parent 9380098534
commit 9196c48256

View File

@ -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;
}