Commit a73d5cd6 authored by Luca Boccassi's avatar Luca Boccassi

Problem: router pipe can block forever

Solution: invert check_write and check_hwm calls in router xsend
function so that check_write can mark the pipe as inactive if
necessary.
parent 1cfc3e17
...@@ -213,26 +213,19 @@ int zmq::router_t::xsend (msg_t *msg_) ...@@ -213,26 +213,19 @@ int zmq::router_t::xsend (msg_t *msg_)
if (it != outpipes.end ()) { if (it != outpipes.end ()) {
current_out = it->second.pipe; current_out = it->second.pipe;
// Check whether pipe is full or not
if (!current_out->check_hwm()) {
it->second.active = false;
current_out = NULL;
if (mandatory) {
more_out = false;
errno = EAGAIN;
return -1;
}
}
// Check whether pipe is closed or not // Check whether pipe is closed or not
else
if (!current_out->check_write()) { if (!current_out->check_write()) {
// Check whether pipe is full or not
bool pipe_full = !current_out->check_hwm ();
it->second.active = false; it->second.active = false;
current_out = NULL; current_out = NULL;
if (mandatory) { if (mandatory) {
more_out = false; more_out = false;
errno = EHOSTUNREACH; if (pipe_full)
errno = EAGAIN;
else
errno = EHOSTUNREACH;
return -1; return -1;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment