mirror of
https://github.com/zeromq/libzmq.git
synced 2025-01-06 00:31:13 +01:00
Merge pull request #487 from miniway/master
returns -1 with EAGAIN when mandatory is set and pipe is full
This commit is contained in:
commit
4febe88b2b
@ -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)
|
|||||||
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)
|
|||||||
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);
|
||||||
|
Loading…
Reference in New Issue
Block a user