mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-31 01:43:02 +08:00
Merge pull request #2143 from minrk/avoid-duplicate-poller-proxy
avoid passing duplicate entries to zmq_poll
This commit is contained in:
commit
872f1e5a9d
@ -130,6 +130,15 @@ int zmq::proxy (
|
|||||||
{ backend_, 0, ZMQ_POLLOUT, 0 }
|
{ backend_, 0, ZMQ_POLLOUT, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int control_idx = 2;
|
||||||
|
if (frontend_ == backend_) {
|
||||||
|
// when frontend & backend are the same,
|
||||||
|
// avoid duplicate poll entries
|
||||||
|
qt_poll_items -= 1;
|
||||||
|
items[1] = items[2];
|
||||||
|
control_idx = 1;
|
||||||
|
}
|
||||||
|
|
||||||
// Proxy can be in these three states
|
// Proxy can be in these three states
|
||||||
enum {
|
enum {
|
||||||
active,
|
active,
|
||||||
@ -154,7 +163,7 @@ int zmq::proxy (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Process a control command if any
|
// Process a control command if any
|
||||||
if (control_ && items [2].revents & ZMQ_POLLIN) {
|
if (control_ && items [control_idx].revents & ZMQ_POLLIN) {
|
||||||
rc = control_->recv (&msg, 0);
|
rc = control_->recv (&msg, 0);
|
||||||
if (unlikely (rc < 0))
|
if (unlikely (rc < 0))
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user