Commit 4febe88b authored by Pieter Hintjens's avatar Pieter Hintjens

Merge pull request #487 from miniway/master

returns -1 with EAGAIN when mandatory is set and pipe is full
parents 2a7b219f a0cecc71
...@@ -159,21 +159,21 @@ int zmq::router_t::xsend (msg_t *msg_) ...@@ -159,21 +159,21 @@ int zmq::router_t::xsend (msg_t *msg_)
// router_mandatory is set. // router_mandatory is set.
blob_t identity ((unsigned char*) msg_->data (), msg_->size ()); blob_t identity ((unsigned char*) msg_->data (), msg_->size ());
outpipes_t::iterator it = outpipes.find (identity); outpipes_t::iterator it = outpipes.find (identity);
bool unreach = false;
if (it != outpipes.end ()) { if (it != outpipes.end ()) {
current_out = it->second.pipe; current_out = it->second.pipe;
if (!current_out->check_write ()) { if (!current_out->check_write ()) {
it->second.active = false; it->second.active = false;
current_out = NULL; current_out = NULL;
unreach = mandatory ? true: false; if (mandatory) {
more_out = false;
errno = EAGAIN;
return -1;
}
} }
} }
else else
if (mandatory) if (mandatory) {
unreach = true;
if (unreach) {
more_out = false; more_out = false;
errno = EHOSTUNREACH; errno = EHOSTUNREACH;
return -1; return -1;
......
...@@ -71,7 +71,7 @@ int main (void) ...@@ -71,7 +71,7 @@ int main (void)
assert (rc == 0); assert (rc == 0);
// wait until connect // wait until connect
zmq_sleep (1); zmq_sleep (1);
// make it full and check that it fails // make it full and check that it fails
rc = zmq_send (sa, "X", 1, ZMQ_SNDMORE); rc = zmq_send (sa, "X", 1, ZMQ_SNDMORE);
...@@ -79,18 +79,17 @@ int main (void) ...@@ -79,18 +79,17 @@ int main (void)
rc = zmq_send (sa, "DATA1", 5, 0); rc = zmq_send (sa, "DATA1", 5, 0);
assert (rc == 5); assert (rc == 5);
rc = zmq_send (sa, "X", 1, ZMQ_SNDMORE | ZMQ_DONTWAIT);
rc = zmq_send (sa, "X", 1, ZMQ_SNDMORE);
if (rc == 1) { if (rc == 1) {
// the first frame has been sent // the first frame has been sent
rc = zmq_send (sa, "DATA2", 5, 0); rc = zmq_send (sa, "DATA2", 5, 0);
assert (rc == 5); assert (rc == 5);
// send more // send more
rc = zmq_send (sa, "X", 1, ZMQ_SNDMORE); rc = zmq_send (sa, "X", 1, ZMQ_SNDMORE | ZMQ_DONTWAIT);
} }
assert (rc == -1 && errno == EHOSTUNREACH); assert (rc == -1 && errno == EAGAIN);
rc = zmq_close (sa); rc = zmq_close (sa);
......
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