diff --git a/src/pipe.cpp b/src/pipe.cpp index 181fe87832..d64f026d26 100644 --- a/src/pipe.cpp +++ b/src/pipe.cpp @@ -537,6 +537,11 @@ bool zmq::pipe_t::check_hwm () const return !full; } +bool zmq::pipe_t::is_active() const +{ + return active == _state; +} + void zmq::pipe_t::send_hwms_to_peer (int inhwm_, int outhwm_) { if (_state == active) diff --git a/src/pipe.hpp b/src/pipe.hpp index b5bc51e1e3..ace3f2e3eb 100644 --- a/src/pipe.hpp +++ b/src/pipe.hpp @@ -115,6 +115,8 @@ class pipe_t ZMQ_FINAL : public object_t, // Returns true if HWM is not reached bool check_hwm () const; + bool is_active () const; + void set_endpoint_pair (endpoint_uri_pair_t endpoint_pair_); const endpoint_uri_pair_t &get_endpoint_pair () const; diff --git a/src/router.cpp b/src/router.cpp index 53ec17c9d3..df4743b28d 100644 --- a/src/router.cpp +++ b/src/router.cpp @@ -185,12 +185,13 @@ int zmq::router_t::xsend (msg_t *msg_) if (!_current_out->check_write ()) { // Check whether pipe is full or not const bool pipe_full = !_current_out->check_hwm (); + const bool pipe_active = _current_out->is_active(); out_pipe->active = false; _current_out = NULL; if (_mandatory) { _more_out = false; - if (pipe_full) + if (pipe_full && pipe_active) errno = EAGAIN; else errno = EHOSTUNREACH;