Problem: REP leaves label msgs for dead REQ in pipe

Solution: roll back the pipe if writing messages other than the
first fails in router::xsend.
Also add test case that reproduces the memory leak when ran with
valgrind.
Fixes #2567
This commit is contained in:
Luca Boccassi
2017-05-10 23:31:17 +01:00
parent d17581929c
commit 0999fdd885
2 changed files with 53 additions and 2 deletions

View File

@@ -273,6 +273,9 @@ int zmq::router_t::xsend (msg_t *msg_)
// Message failed to send - we must close it ourselves.
int rc = msg_->close ();
errno_assert (rc == 0);
// HWM was checked before, so the pipe must be gone. Roll back
// messages that were piped, for example REP labels.
current_out->rollback ();
current_out = NULL;
} else {
if (!more_out) {