mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-27 02:53:12 +01:00
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)
This commit is contained in:
@@ -246,14 +246,18 @@ int zmq::router_t::xsend (msg_t *msg_)
|
||||
}
|
||||
|
||||
bool ok = current_out->write (msg_);
|
||||
if (unlikely (!ok))
|
||||
if (unlikely (!ok)) {
|
||||
// Message failed to send - we must close it ourselves.
|
||||
int rc = msg_->close ();
|
||||
errno_assert (rc == 0);
|
||||
current_out = NULL;
|
||||
else
|
||||
} else {
|
||||
if (!more_out) {
|
||||
current_out->flush ();
|
||||
current_out = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
int rc = msg_->close ();
|
||||
errno_assert (rc == 0);
|
||||
|
||||
Reference in New Issue
Block a user