diff --git a/src/proxy.cpp b/src/proxy.cpp index 738a77ae..6e05d8a8 100644 --- a/src/proxy.cpp +++ b/src/proxy.cpp @@ -142,10 +142,14 @@ int zmq::proxy ( return -1; // Get the pollout separately because when combining this with pollin it maxes the CPU - // because pollout shall most of the time return directly - rc = zmq_poll (&itemsout [0], 2, 0); - if (unlikely (rc < 0)) - return -1; + // because pollout shall most of the time return directly. + // POLLOUT is only checked when frontend and backend sockets are not the same. + if (frontend_ != backend_) { + rc = zmq_poll (&itemsout [0], 2, 0); + if (unlikely (rc < 0)) { + return -1; + } + } // Process a control command if any if (control_ && items [2].revents & ZMQ_POLLIN) { @@ -180,13 +184,14 @@ int zmq::proxy ( // Process a request if (state == active && items [0].revents & ZMQ_POLLIN - && itemsout [1].revents & ZMQ_POLLOUT) { + && (frontend_ == backend_ || itemsout [1].revents & ZMQ_POLLOUT)) { rc = forward(frontend_, backend_, capture_,msg); if (unlikely (rc < 0)) return -1; } // Process a reply if (state == active + && frontend_ != backend_ && items [1].revents & ZMQ_POLLIN && itemsout [0].revents & ZMQ_POLLOUT) { rc = forward(backend_, frontend_, capture_,msg);