Commit 91e121c9 authored by Doron Somech's avatar Doron Somech Committed by GitHub

Merge pull request #2139 from minrk/update-poll-based-on-poll

update socket_poller when ZMQ_POLL_BASED_ON_SELECT
parents c7518993 e50a9876
......@@ -440,7 +440,7 @@ int zmq::socket_poller_t::wait (zmq::socket_poller_t::event_t *events_, int n_ev
signaler.recv ();
// Check for the events.
int i=0;
int i = 0;
for (items_t::iterator it = items.begin (); it != items.end () && i < n_events_; ++i, ++it) {
events_[i].socket = NULL;
......@@ -548,6 +548,7 @@ int zmq::socket_poller_t::wait (zmq::socket_poller_t::event_t *events_, int n_ev
uint64_t end = 0;
bool first_pass = true;
bool found = false;
fd_set inset, outset, errset;
while (true) {
......@@ -595,7 +596,8 @@ int zmq::socket_poller_t::wait (zmq::socket_poller_t::event_t *events_, int n_ev
signaler.recv ();
// Check for the events.
for (items_t::iterator it = items.begin (); it != items.end (); ++it) {
int i = 0;
for (items_t::iterator it = items.begin (); it != items.end () && i < n_events_; ++i, ++it) {
// The poll item is a 0MQ socket. Retrieve pending events
// using the ZMQ_EVENTS socket option.
......@@ -606,12 +608,10 @@ int zmq::socket_poller_t::wait (zmq::socket_poller_t::event_t *events_, int n_ev
return -1;
if (it->events & events) {
event_->socket = it->socket;
event_->user_data = it->user_data;
event_->events = it->events & events;
// If there is event to return, we can exit immediately.
return 0;
events_[i].socket = it->socket;
events_[i].user_data = it->user_data;
events_[i].events = it->events & events;
found = true;
}
}
// Else, the poll item is a raw file descriptor, simply convert
......@@ -627,16 +627,17 @@ int zmq::socket_poller_t::wait (zmq::socket_poller_t::event_t *events_, int n_ev
events |= ZMQ_POLLERR;
if (events) {
event_->socket = NULL;
event_->user_data = it->user_data;
event_->fd = it->fd;
event_->events = events;
// If there is event to return, we can exit immediately.
return 0;
events_[i].socket = NULL;
events_[i].user_data = it->user_data;
events_[i].fd = it->fd;
events_[i].events = events;
found = true;
}
}
}
if (found) {
return 0;
}
// If timeout is zero, exit immediately whether there are events or not.
if (timeout_ == 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