Commit 866a0465 authored by Topher Brown's avatar Topher Brown

Close messages that failed to send

pipe_t.write only takes control of the underlying message memory when it
succeeds. When it returns failure, we must close the message ourselves to
clean up that memory.

This patch is sponsored by FarSounder, Inc (farsounder.com)
parent 94b0ad3e
......@@ -246,12 +246,16 @@ int zmq::router_t::xsend (msg_t *msg_)
}
bool ok = current_out->write (msg_);
if (unlikely (!ok))
current_out = NULL;
else
if (!more_out) {
current_out->flush ();
if (unlikely (!ok)) {
// Message failed to send - we must close it ourselves.
int rc = msg_->close ();
errno_assert (rc == 0);
current_out = NULL;
} else {
if (!more_out) {
current_out->flush ();
current_out = NULL;
}
}
}
else {
......
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