diff --git a/src/stream.cpp b/src/stream.cpp index 7d10b62b86..4c85625b6b 100644 --- a/src/stream.cpp +++ b/src/stream.cpp @@ -79,9 +79,6 @@ int zmq::stream_t::xsend (msg_t *msg_) _current_out = out_pipe->pipe; if (!_current_out->check_write ()) { out_pipe->active = false; - _current_out = NULL; - errno = EAGAIN; - return -1; } } else { errno = EHOSTUNREACH; @@ -119,6 +116,13 @@ int zmq::stream_t::xsend (msg_t *msg_) _current_out = NULL; return 0; } + if (!_current_out->check_write ()) { + // Because we set _more_out to false above, the user is forced + // to resend the Identity frame on their next attempt. + _current_out = NULL; + errno = EAGAIN; + return -1; + } const bool ok = _current_out->write (msg_); if (likely (ok)) _current_out->flush (); @@ -261,4 +265,4 @@ void zmq::stream_t::identify_peer (pipe_t *pipe_, bool locally_initiated_) } pipe_->set_router_socket_routing_id (routing_id); add_out_pipe (ZMQ_MOVE (routing_id), pipe_); -} +} \ No newline at end of file