mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-10 16:06:09 +00:00
Problem: proxy leaks one message payload (0..n bytes) on close.
This commit is contained in:
parent
4ea7d01803
commit
1b79da0d7d
@ -143,7 +143,7 @@ int zmq::proxy (
|
||||
// Wait while there are either requests or replies to process.
|
||||
rc = zmq_poll (&items [0], qt_poll_items, -1);
|
||||
if (unlikely (rc < 0))
|
||||
return -1;
|
||||
return close_and_return (&msg, -1);
|
||||
|
||||
// Get the pollout separately because when combining this with pollin it maxes the CPU
|
||||
// because pollout shall most of the time return directly.
|
||||
@ -151,7 +151,7 @@ int zmq::proxy (
|
||||
if (frontend_ != backend_) {
|
||||
rc = zmq_poll (&itemsout [0], 2, 0);
|
||||
if (unlikely (rc < 0)) {
|
||||
return -1;
|
||||
return close_and_return (&msg, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -159,17 +159,17 @@ int zmq::proxy (
|
||||
if (control_ && items [2].revents & ZMQ_POLLIN) {
|
||||
rc = control_->recv (&msg, 0);
|
||||
if (unlikely (rc < 0))
|
||||
return -1;
|
||||
return close_and_return (&msg, -1);
|
||||
|
||||
moresz = sizeof more;
|
||||
rc = control_->getsockopt (ZMQ_RCVMORE, &more, &moresz);
|
||||
if (unlikely (rc < 0) || more)
|
||||
return -1;
|
||||
return close_and_return (&msg, -1);
|
||||
|
||||
// Copy message to capture socket if any
|
||||
rc = capture (capture_, msg);
|
||||
if (unlikely (rc < 0))
|
||||
return -1;
|
||||
return close_and_return (&msg, -1);
|
||||
|
||||
if (msg.size () == 5 && memcmp (msg.data (), "PAUSE", 5) == 0)
|
||||
state = paused;
|
||||
@ -180,7 +180,7 @@ int zmq::proxy (
|
||||
if (msg.size () == 9 && memcmp (msg.data (), "TERMINATE", 9) == 0)
|
||||
state = terminated;
|
||||
else {
|
||||
// This is an API error, we should assert
|
||||
// This is an API error, so we assert
|
||||
puts ("E: invalid command sent to proxy");
|
||||
zmq_assert (false);
|
||||
}
|
||||
@ -191,7 +191,7 @@ int zmq::proxy (
|
||||
&& (frontend_ == backend_ || itemsout [1].revents & ZMQ_POLLOUT)) {
|
||||
rc = forward (frontend_, backend_, capture_, msg);
|
||||
if (unlikely (rc < 0))
|
||||
return -1;
|
||||
return close_and_return (&msg, -1);
|
||||
}
|
||||
// Process a reply
|
||||
if (state == active
|
||||
@ -200,8 +200,9 @@ int zmq::proxy (
|
||||
&& itemsout [0].revents & ZMQ_POLLOUT) {
|
||||
rc = forward (backend_, frontend_, capture_, msg);
|
||||
if (unlikely (rc < 0))
|
||||
return -1;
|
||||
return close_and_return (&msg, -1);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
return close_and_return (&msg, 0);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user