Problem: routing ID cycles back to zero

It should never be zero.

Solution: if rid cycles back to zero, bump to 1.
This commit is contained in:
Pieter Hintjens 2015-09-11 14:30:27 -04:00
parent 60fdfd9a1b
commit 5e936fe955

View File

@ -54,6 +54,9 @@ void zmq::server_t::xattach_pipe (pipe_t *pipe_, bool subscribe_to_all_)
zmq_assert (pipe_);
uint32_t routing_id = next_rid++;
if (!routing_id)
routing_id = next_rid++; // Never use RID zero
pipe_->set_routing_id (routing_id);
// Add the record into output pipes lookup table
outpipe_t outpipe = {pipe_, true};
@ -113,9 +116,10 @@ int zmq::server_t::xsend (msg_t *msg_)
// Message failed to send - we must close it ourselves.
int rc = msg_->close ();
errno_assert (rc == 0);
} else {
it->second.pipe->flush ();
}
else
it->second.pipe->flush ();
// Detach the message from the data buffer.
int rc = msg_->init ();