Revert "add a proxy hook"

This reverts commit 9ae6a91fad.
This commit is contained in:
Laurent Alebarde
2014-02-13 18:33:52 +01:00
parent bc25366f7c
commit abf9d8b74e
6 changed files with 23 additions and 348 deletions

View File

@@ -53,8 +53,7 @@
// zmq.h must be included *after* poll.h for AIX to build properly
#include "../include/zmq.h"
int
capture(
int capture(
class zmq::socket_base_t *capture_,
zmq::msg_t& msg_,
int more_ = 0)
@@ -75,18 +74,15 @@ capture(
return 0;
}
int
forward(
int forward(
class zmq::socket_base_t *from_,
class zmq::socket_base_t *to_,
class zmq::socket_base_t *capture_,
zmq::msg_t& msg_,
zmq::hook_f do_hook_,
void *data_)
zmq::msg_t& msg_)
{
int more;
size_t moresz;
for (size_t n = 1;; n++) {
while (true) {
int rc = from_->recv (&msg_, 0);
if (unlikely (rc < 0))
return -1;
@@ -101,13 +97,6 @@ forward(
if (unlikely (rc < 0))
return -1;
// Hook
if (do_hook_) {
rc = (*do_hook_)(from_, to_, capture_, &msg_, more ? n : 0, data_); // first message: n == 1, mth message: n == m, last message: n == 0
if (unlikely (rc < 0))
return -1;
}
rc = to_->send (&msg_, more? ZMQ_SNDMORE: 0);
if (unlikely (rc < 0))
return -1;
@@ -117,16 +106,12 @@ forward(
return 0;
}
int
zmq::proxy (
int zmq::proxy (
class socket_base_t *frontend_,
class socket_base_t *backend_,
class socket_base_t *capture_,
class socket_base_t *control_,
zmq::proxy_hook_t *hook_)
class socket_base_t *control_)
{
static zmq::proxy_hook_t dummy_hook = {NULL, NULL, NULL};
msg_t msg;
int rc = msg.init ();
if (rc != 0)
@@ -187,20 +172,17 @@ zmq::proxy (
zmq_assert (false);
}
}
// Check if a hook is used
if (!hook_)
hook_ = &dummy_hook;
// Process a request
if (state == active
&& items [0].revents & ZMQ_POLLIN) {
rc = forward(frontend_, backend_, capture_, msg, hook_->front2back_hook, hook_->data);
rc = forward(frontend_, backend_, capture_,msg);
if (unlikely (rc < 0))
return -1;
}
// Process a reply
if (state == active
&& items [1].revents & ZMQ_POLLIN) {
rc = forward(backend_, frontend_, capture_, msg, hook_->back2front_hook, hook_->data);
rc = forward(backend_, frontend_, capture_,msg);
if (unlikely (rc < 0))
return -1;
}