Commit c1a4cfdd authored by sigiesec's avatar sigiesec

Problem: waiting on an empty poller with infinite timeout waits forever

Solution: return EFAULT when such an operation is attempted
parent 0c9b16d6
......@@ -400,6 +400,11 @@ int zmq::socket_poller_t::rebuild ()
int zmq::socket_poller_t::wait (zmq::socket_poller_t::event_t *events_, int n_events_, long timeout_)
{
if (items.empty () && timeout_ < 0) {
errno = EFAULT;
return -1;
}
if (need_rebuild)
if (rebuild () == -1)
return -1;
......
......@@ -180,20 +180,16 @@ void test_wait_corner_cases (void *ctx)
int rc = zmq_poller_wait(poller, &event, 0);
assert (rc == -1 && errno == ETIMEDOUT);
// TODO this can never return, and should yield an error
#if 0
// this can never return since no socket was registered, and should yield an error
rc = zmq_poller_wait(poller, &event, -1);
assert (rc == 0);
#endif
assert (rc == -1 && errno == EFAULT);
rc = zmq_poller_wait_all (poller, &event, 0, 0);
assert (rc == -1 && errno == ETIMEDOUT);
// TODO this can never return, and should yield an error
#if 0
// this can never return since no socket was registered, and should yield an error
rc = zmq_poller_wait_all (poller, &event, 0, -1);
assert (rc == 0);
#endif
assert (rc == -1 && errno == EFAULT);
rc = zmq_poller_destroy (&poller);
assert (rc == 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment