From 313b5dfadd8753b341197cc109bce40e08856cf6 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Fri, 12 Feb 2010 19:42:35 +0100 Subject: Multi-hop REQ/REP, part III., change 'type' in options to simple 'traceroute' flag --- src/downstream.cpp | 1 - src/options.cpp | 4 ++-- src/options.hpp | 6 +++--- src/p2p.cpp | 1 - src/pub.cpp | 1 - src/rep.cpp | 1 - src/req.cpp | 1 - src/sub.cpp | 1 - src/upstream.cpp | 1 - src/xrep.cpp | 5 ++++- src/xreq.cpp | 1 - src/zmq_init.cpp | 2 +- 12 files changed, 10 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/downstream.cpp b/src/downstream.cpp index 29b0689..2da08e3 100644 --- a/src/downstream.cpp +++ b/src/downstream.cpp @@ -26,7 +26,6 @@ zmq::downstream_t::downstream_t (class app_thread_t *parent_) : socket_base_t (parent_) { - options.type = ZMQ_DOWNSTREAM; options.requires_in = false; options.requires_out = true; } diff --git a/src/options.cpp b/src/options.cpp index f9d93d6..cdfccc6 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -23,7 +23,6 @@ #include "err.hpp" zmq::options_t::options_t () : - type (-1), hwm (0), lwm (0), swap (0), @@ -34,7 +33,8 @@ zmq::options_t::options_t () : sndbuf (0), rcvbuf (0), requires_in (false), - requires_out (false) + requires_out (false), + traceroute (false) { } diff --git a/src/options.hpp b/src/options.hpp index dbe3701..f9ff6e4 100644 --- a/src/options.hpp +++ b/src/options.hpp @@ -34,9 +34,6 @@ namespace zmq int setsockopt (int option_, const void *optval_, size_t optvallen_); - // Type of the associated socket. One of the constants defined in zmq.h - int type; - int64_t hwm; int64_t lwm; int64_t swap; @@ -59,6 +56,9 @@ namespace zmq // provided by the specific socket type. bool requires_in; bool requires_out; + + // If true, socket requires tracerouting the messages. + bool traceroute; }; } diff --git a/src/p2p.cpp b/src/p2p.cpp index 46bbd0b..72bc26b 100644 --- a/src/p2p.cpp +++ b/src/p2p.cpp @@ -29,7 +29,6 @@ zmq::p2p_t::p2p_t (class app_thread_t *parent_) : outpipe (NULL), alive (true) { - options.type = ZMQ_P2P; options.requires_in = true; options.requires_out = true; } diff --git a/src/pub.cpp b/src/pub.cpp index 9a2dcc6..05bfdcf 100644 --- a/src/pub.cpp +++ b/src/pub.cpp @@ -27,7 +27,6 @@ zmq::pub_t::pub_t (class app_thread_t *parent_) : socket_base_t (parent_) { - options.type = ZMQ_PUB; options.requires_in = false; options.requires_out = true; } diff --git a/src/rep.cpp b/src/rep.cpp index b7685b4..b6bffae 100644 --- a/src/rep.cpp +++ b/src/rep.cpp @@ -30,7 +30,6 @@ zmq::rep_t::rep_t (class app_thread_t *parent_) : waiting_for_reply (false), reply_pipe (NULL) { - options.type = ZMQ_REP; options.requires_in = true; options.requires_out = true; } diff --git a/src/req.cpp b/src/req.cpp index 9b1766e..c9240e0 100644 --- a/src/req.cpp +++ b/src/req.cpp @@ -30,7 +30,6 @@ zmq::req_t::req_t (class app_thread_t *parent_) : reply_pipe_active (false), reply_pipe (NULL) { - options.type = ZMQ_REQ; options.requires_in = true; options.requires_out = true; } diff --git a/src/sub.cpp b/src/sub.cpp index 31ee222..06ed896 100644 --- a/src/sub.cpp +++ b/src/sub.cpp @@ -28,7 +28,6 @@ zmq::sub_t::sub_t (class app_thread_t *parent_) : socket_base_t (parent_), has_message (false) { - options.type = ZMQ_SUB; options.requires_in = true; options.requires_out = false; zmq_msg_init (&message); diff --git a/src/upstream.cpp b/src/upstream.cpp index 390dcbe..bdcd5ef 100644 --- a/src/upstream.cpp +++ b/src/upstream.cpp @@ -25,7 +25,6 @@ zmq::upstream_t::upstream_t (class app_thread_t *parent_) : socket_base_t (parent_) { - options.type = ZMQ_UPSTREAM; options.requires_in = true; options.requires_out = false; } diff --git a/src/xrep.cpp b/src/xrep.cpp index 67a9a39..9462a60 100644 --- a/src/xrep.cpp +++ b/src/xrep.cpp @@ -25,9 +25,12 @@ zmq::xrep_t::xrep_t (class app_thread_t *parent_) : socket_base_t (parent_) { - options.type = ZMQ_XREP; options.requires_in = true; options.requires_out = true; + + // XREP socket adds identity to inbound messages and strips identity + // from the outbound messages. + options.traceroute = true; } zmq::xrep_t::~xrep_t () diff --git a/src/xreq.cpp b/src/xreq.cpp index 691b66e..a4310f8 100644 --- a/src/xreq.cpp +++ b/src/xreq.cpp @@ -25,7 +25,6 @@ zmq::xreq_t::xreq_t (class app_thread_t *parent_) : socket_base_t (parent_) { - options.type = ZMQ_REQ; options.requires_in = true; options.requires_out = true; } diff --git a/src/zmq_init.cpp b/src/zmq_init.cpp index 9492caa..b49baa9 100644 --- a/src/zmq_init.cpp +++ b/src/zmq_init.cpp @@ -78,7 +78,7 @@ bool zmq::zmq_init_t::write (::zmq_msg_t *msg_) // Once the initial handshaking is over, XREP sockets should start // tracerouting individual messages. - if (options.type == ZMQ_XREP) + if (options.traceroute) engine->traceroute ((unsigned char*) peer_identity.data (), peer_identity.size ()); -- cgit v1.2.3