Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the bug that the router may block forever when the sending queue is full #4665

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/pipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/pipe.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion src/router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading