Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -Nu -x '*.la' -x '*.lo' -x '*.o' -x '*.pc' -x .libs -x .deps -x Makefile -x platform.hpp -x stamp-h1 zeromq-3.2.2/src/pgm_receiver.cpp zeromq-3.2.2.1/src/pgm_receiver.cpp
- --- zeromq-3.2.2/src/pgm_receiver.cpp 2012-10-25 03:30:40.000000000 -0500
- +++ zeromq-3.2.2.1/src/pgm_receiver.cpp 2013-03-28 08:32:49.000000000 -0500
- @@ -73,6 +73,8 @@
- session = session_;
- + session->set_identity_received(true);
- +
- // If there are any subscriptions already queued in the session, drop them.
- drop_subscriptions ();
- }
- diff -Nu -x '*.la' -x '*.lo' -x '*.o' -x '*.pc' -x .libs -x .deps -x Makefile -x platform.hpp -x stamp-h1 zeromq-3.2.2/src/pgm_sender.cpp zeromq-3.2.2.1/src/pgm_sender.cpp
- --- zeromq-3.2.2/src/pgm_sender.cpp 2012-10-25 03:30:40.000000000 -0500
- +++ zeromq-3.2.2.1/src/pgm_sender.cpp 2013-03-28 12:40:43.000000000 -0500
- @@ -72,6 +72,8 @@
- fd_t rdata_notify_fd = retired_fd;
- fd_t pending_notify_fd = retired_fd;
- + session_->set_identity_sent(true);
- +
- encoder.set_msg_source (session_);
- // Fill fds from PGM transport and add them to the poller.
- diff -Nu -x '*.la' -x '*.lo' -x '*.o' -x '*.pc' -x .libs -x .deps -x Makefile -x platform.hpp -x stamp-h1 zeromq-3.2.2/src/session_base.cpp zeromq-3.2.2.1/src/session_base.cpp
- --- zeromq-3.2.2/src/session_base.cpp 2012-11-13 19:09:14.000000000 -0600
- +++ zeromq-3.2.2.1/src/session_base.cpp 2013-03-28 12:37:35.000000000 -0500
- @@ -140,6 +140,17 @@
- delete addr;
- }
- +void zmq::session_base_t::set_identity_received(bool b)
- +{
- + identity_received = b;
- +}
- +
- +void zmq::session_base_t::set_identity_sent(bool b)
- +{
- + identity_sent = b;
- +}
- +
- +
- void zmq::session_base_t::attach_pipe (pipe_t *pipe_)
- {
- zmq_assert (!is_terminating ());
- diff -Nu -x '*.la' -x '*.lo' -x '*.o' -x '*.pc' -x .libs -x .deps -x Makefile -x platform.hpp -x stamp-h1 zeromq-3.2.2/src/session_base.hpp zeromq-3.2.2.1/src/session_base.hpp
- --- zeromq-3.2.2/src/session_base.hpp 2012-10-25 03:30:40.000000000 -0500
- +++ zeromq-3.2.2.1/src/session_base.hpp 2013-03-28 12:37:43.000000000 -0500
- @@ -78,6 +78,9 @@
- socket_base_t *get_socket ();
- + void set_identity_received(bool b);
- + void set_identity_sent(bool b);
- +
- protected:
- session_base_t (zmq::io_thread_t *io_thread_, bool connect_,
- diff -Nu -x '*.la' -x '*.lo' -x '*.o' -x '*.pc' -x .libs -x .deps -x Makefile -x platform.hpp -x stamp-h1 zeromq-3.2.2/src/socket_base.cpp zeromq-3.2.2.1/src/socket_base.cpp
- --- zeromq-3.2.2/src/socket_base.cpp 2012-11-23 01:54:28.000000000 -0600
- +++ zeromq-3.2.2.1/src/socket_base.cpp 2013-03-28 17:01:20.000000000 -0500
- @@ -300,6 +300,18 @@
- return 0;
- }
- + if (option_ == ZMQ_GET_CLOSURE) {
- + if (*optvallen_ < sizeof(void*)) {
- + errno = EINVAL;
- + return -1;
- + }
- + void *cv = xget_closure();
- + void **closure_ptr = (void**)optval_;
- + *closure_ptr = cv;
- + *optvallen_ = sizeof(void*);
- + return 0;
- + }
- +
- return options.getsockopt (option_, optval_, optvallen_);
- }
- @@ -770,6 +782,18 @@
- return xhas_out ();
- }
- +int zmq::socket_base_t::xset_closure (const char *filter, size_t size, void * closure)
- +{
- + errno = EINVAL;
- + return -1;
- +}
- +
- +void* zmq::socket_base_t::xget_closure ()
- +{
- + return NULL;
- +}
- +
- +
- void zmq::socket_base_t::start_reaping (poller_t *poller_)
- {
- // Plug the socket to the reaper thread.
- diff -Nu -x '*.la' -x '*.lo' -x '*.o' -x '*.pc' -x .libs -x .deps -x Makefile -x platform.hpp -x stamp-h1 zeromq-3.2.2/src/socket_base.hpp zeromq-3.2.2.1/src/socket_base.hpp
- --- zeromq-3.2.2/src/socket_base.hpp 2012-11-23 01:54:28.000000000 -0600
- +++ zeromq-3.2.2.1/src/socket_base.hpp 2013-03-28 16:17:24.000000000 -0500
- @@ -150,6 +150,9 @@
- virtual void xhiccuped (pipe_t *pipe_);
- virtual void xterminated (pipe_t *pipe_) = 0;
- + virtual int xset_closure (const char *filter, size_t size, void *closure);
- + virtual void* xget_closure ();
- +
- // Delay actual destruction of the socket.
- void process_destroy ();
- diff -Nu -x '*.la' -x '*.lo' -x '*.o' -x '*.pc' -x .libs -x .deps -x Makefile -x platform.hpp -x stamp-h1 zeromq-3.2.2/src/sub.cpp zeromq-3.2.2.1/src/sub.cpp
- --- zeromq-3.2.2/src/sub.cpp 2012-10-25 03:30:40.000000000 -0500
- +++ zeromq-3.2.2.1/src/sub.cpp 2013-03-28 17:00:34.000000000 -0500
- @@ -39,32 +39,39 @@
- int zmq::sub_t::xsetsockopt (int option_, const void *optval_,
- size_t optvallen_)
- {
- - if (option_ != ZMQ_SUBSCRIBE && option_ != ZMQ_UNSUBSCRIBE) {
- - errno = EINVAL;
- - return -1;
- + if (option_ == ZMQ_SUBSCRIBE || option_ == ZMQ_UNSUBSCRIBE) {
- + // Create the subscription message.
- + msg_t msg;
- + int rc = msg.init_size (optvallen_ + 1);
- + errno_assert (rc == 0);
- + unsigned char *data = (unsigned char*) msg.data ();
- + if (option_ == ZMQ_SUBSCRIBE)
- + *data = 1;
- + else if (option_ == ZMQ_UNSUBSCRIBE)
- + *data = 0;
- + memcpy (data + 1, optval_, optvallen_);
- +
- + // Pass it further on in the stack.
- + int err = 0;
- + rc = xsub_t::xsend (&msg, 0);
- + if (rc != 0)
- + err = errno;
- + int rc2 = msg.close ();
- + errno_assert (rc2 == 0);
- + if (rc != 0)
- + errno = err;
- + return rc;
- }
- -
- - // Create the subscription message.
- - msg_t msg;
- - int rc = msg.init_size (optvallen_ + 1);
- - errno_assert (rc == 0);
- - unsigned char *data = (unsigned char*) msg.data ();
- - if (option_ == ZMQ_SUBSCRIBE)
- - *data = 1;
- - else if (option_ == ZMQ_UNSUBSCRIBE)
- - *data = 0;
- - memcpy (data + 1, optval_, optvallen_);
- -
- - // Pass it further on in the stack.
- - int err = 0;
- - rc = xsub_t::xsend (&msg, 0);
- - if (rc != 0)
- - err = errno;
- - int rc2 = msg.close ();
- - errno_assert (rc2 == 0);
- - if (rc != 0)
- - errno = err;
- - return rc;
- + else if (option_ == ZMQ_SET_CLOSURE) {
- + if (optvallen_ == sizeof(zmq_closure_t)) {
- + const zmq_closure_t *closure = static_cast<const zmq_closure_t*>(optval_);
- + int rc = xset_closure (closure->filter, closure->size, closure->closure);
- + if (!rc)
- + return rc;
- + }
- + }
- + errno = EINVAL;
- + return -1;
- }
- int zmq::sub_t::xsend (msg_t *, int)
- diff -Nu -x '*.la' -x '*.lo' -x '*.o' -x '*.pc' -x .libs -x .deps -x Makefile -x platform.hpp -x stamp-h1 zeromq-3.2.2/src/trie.cpp zeromq-3.2.2.1/src/trie.cpp
- --- zeromq-3.2.2/src/trie.cpp 2012-10-25 03:30:40.000000000 -0500
- +++ zeromq-3.2.2.1/src/trie.cpp 2013-03-28 13:14:51.000000000 -0500
- @@ -35,6 +35,7 @@
- zmq::trie_t::trie_t () :
- refcnt (0),
- + closure_value (0),
- min (0),
- count (0),
- live_nodes (0)
- @@ -253,38 +254,24 @@
- return ret;
- }
- -bool zmq::trie_t::check (unsigned char *data_, size_t size_)
- +bool zmq::trie_t::set_closure( const unsigned char *prefix, size_t size, void *closure)
- {
- - // This function is on critical path. It deliberately doesn't use
- - // recursion to get a bit better performance.
- - trie_t *current = this;
- - while (true) {
- -
- - // We've found a corresponding subscription!
- - if (current->refcnt)
- - return true;
- -
- - // We've checked all the data and haven't found matching subscription.
- - if (!size_)
- - return false;
- -
- - // If there's no corresponding slot for the first character
- - // of the prefix, the message does not match.
- - unsigned char c = *data_;
- - if (c < current->min || c >= current->min + current->count)
- - return false;
- -
- - // Move to the next character.
- - if (current->count == 1)
- - current = current->next.node;
- - else {
- - current = current->next.table [c - current->min];
- - if (!current)
- - return false;
- - }
- - data_++;
- - size_--;
- + trie_t *node = find_node(prefix, size);
- + if (node) {
- + node->closure_value = closure;
- + return true;
- + }
- + return false;
- +}
- +
- +bool zmq::trie_t::check (unsigned char *data_, size_t size_, void*& closure)
- +{
- + trie_t *node = find_node(data_, size_);
- + if (node) {
- + closure = node->closure_value;
- + return true;
- }
- + return false;
- }
- void zmq::trie_t::apply (void (*func_) (unsigned char *data_, size_t size_,
- diff -Nu -x '*.la' -x '*.lo' -x '*.o' -x '*.pc' -x .libs -x .deps -x Makefile -x platform.hpp -x stamp-h1 zeromq-3.2.2/src/trie.hpp zeromq-3.2.2.1/src/trie.hpp
- --- zeromq-3.2.2/src/trie.hpp 2012-10-25 03:30:40.000000000 -0500
- +++ zeromq-3.2.2.1/src/trie.hpp 2013-03-28 12:24:07.000000000 -0500
- @@ -41,12 +41,14 @@
- // rather than a duplicate.
- bool add (unsigned char *prefix_, size_t size_);
- + bool set_closure( const unsigned char *prefix, size_t size, void *closure);
- +
- // Remove key from the trie. Returns true if the item is actually
- // removed from the trie.
- bool rm (unsigned char *prefix_, size_t size_);
- // Check whether particular key is in the trie.
- - bool check (unsigned char *data_, size_t size_);
- + bool check (unsigned char *data_, size_t size_, void*& closure);
- // Apply the function supplied to each subscription in the trie.
- void apply (void (*func_) (unsigned char *data_, size_t size_,
- @@ -60,7 +62,10 @@
- void *arg_);
- bool is_redundant () const;
- + trie_t *find_node (const unsigned char *data_, size_t size_);
- +
- uint32_t refcnt;
- + void *closure_value;
- unsigned char min;
- unsigned short count;
- unsigned short live_nodes;
- @@ -73,6 +78,40 @@
- const trie_t &operator = (const trie_t&);
- };
- + inline trie_t * trie_t::find_node (const unsigned char *data_, size_t size_)
- + {
- + // This function is on critical path. It deliberately doesn't use
- + // recursion to get a bit better performance.
- + trie_t *current = this;
- + while (true) {
- +
- + // We've found a corresponding subscription!
- + if (current->refcnt) {
- + return current;
- + }
- +
- + // We've checked all the data and haven't found matching subscription.
- + if (!size_)
- + return NULL;
- +
- + // If there's no corresponding slot for the first character
- + // of the prefix, the message does not match.
- + unsigned char c = *data_;
- + if (c < current->min || c >= current->min + current->count)
- + return NULL;
- +
- + // Move to the next character.
- + if (current->count == 1)
- + current = current->next.node;
- + else {
- + current = current->next.table [c - current->min];
- + if (!current)
- + return NULL;
- + }
- + data_++;
- + size_--;
- + }
- + }
- }
- #endif
- diff -Nu -x '*.la' -x '*.lo' -x '*.o' -x '*.pc' -x .libs -x .deps -x Makefile -x platform.hpp -x stamp-h1 zeromq-3.2.2/src/xsub.cpp zeromq-3.2.2.1/src/xsub.cpp
- --- zeromq-3.2.2/src/xsub.cpp 2012-10-25 03:30:40.000000000 -0500
- +++ zeromq-3.2.2.1/src/xsub.cpp 2013-03-28 16:59:03.000000000 -0500
- @@ -27,6 +27,7 @@
- zmq::xsub_t::xsub_t (class ctx_t *parent_, uint32_t tid_, int sid_) :
- socket_base_t (parent_, tid_, sid_),
- has_message (false),
- + current_closure (NULL),
- more (false)
- {
- options.type = ZMQ_XSUB;
- @@ -75,6 +76,16 @@
- dist.terminated (pipe_);
- }
- +int zmq::xsub_t::xset_closure (const char *filter, size_t size, void *closure)
- +{
- + return subscriptions.set_closure ((unsigned char*) filter, size, closure) != true;
- +}
- +
- +void* zmq::xsub_t::xget_closure ()
- +{
- + return current_closure;
- +}
- +
- void zmq::xsub_t::xhiccuped (pipe_t *pipe_)
- {
- // Send all the cached subscriptions to the hiccuped pipe.
- @@ -147,7 +158,7 @@
- // Check whether the message matches at least one subscription.
- // Non-initial parts of the message are passed
- - if (more || !options.filter || match (msg_)) {
- + if (more || !options.filter || match (msg_, current_closure)) {
- more = msg_->flags () & msg_t::more ? true : false;
- return 0;
- }
- @@ -187,7 +198,7 @@
- }
- // Check whether the message matches at least one subscription.
- - if (!options.filter || match (&message)) {
- + if (!options.filter || match (&message, current_closure)) {
- has_message = true;
- return true;
- }
- @@ -201,9 +212,9 @@
- }
- }
- -bool zmq::xsub_t::match (msg_t *msg_)
- +bool zmq::xsub_t::match (msg_t *msg_, void*& closure)
- {
- - return subscriptions.check ((unsigned char*) msg_->data (), msg_->size ());
- + return subscriptions.check ((unsigned char*) msg_->data (), msg_->size (), closure);
- }
- void zmq::xsub_t::send_subscription (unsigned char *data_, size_t size_,
- diff -Nu -x '*.la' -x '*.lo' -x '*.o' -x '*.pc' -x .libs -x .deps -x Makefile -x platform.hpp -x stamp-h1 zeromq-3.2.2/src/xsub.hpp zeromq-3.2.2.1/src/xsub.hpp
- --- zeromq-3.2.2/src/xsub.hpp 2012-10-25 03:30:40.000000000 -0500
- +++ zeromq-3.2.2.1/src/xsub.hpp 2013-03-28 16:57:36.000000000 -0500
- @@ -54,11 +54,13 @@
- void xwrite_activated (zmq::pipe_t *pipe_);
- void xhiccuped (pipe_t *pipe_);
- void xterminated (zmq::pipe_t *pipe_);
- + int xset_closure (const char *filter, size_t size, void *closure);
- + void* xget_closure ();
- private:
- // Check whether the message matches at least one subscription.
- - bool match (zmq::msg_t *msg_);
- + bool match (zmq::msg_t *msg_, void*& closure);
- // Function to be applied to the trie to send all the subsciptions
- // upstream.
- @@ -77,6 +79,7 @@
- // If true, 'message' contains a matching message to return on the
- // next recv call.
- bool has_message;
- + void* current_closure;
- msg_t message;
- // If true, part of a multipart message was already received, but
- diff -Nu zeromq-3.2.2/include/zmq.h zeromq-3.2.2.1/include/zmq.h
- --- zeromq-3.2.2/include/zmq.h 2012-11-13 19:09:14.000000000 -0600
- +++ zeromq-3.2.2.1/include/zmq.h 2013-03-28 16:23:04.000000000 -0500
- @@ -250,6 +250,8 @@
- #define ZMQ_TCP_ACCEPT_FILTER 38
- #define ZMQ_DELAY_ATTACH_ON_CONNECT 39
- #define ZMQ_XPUB_VERBOSE 40
- +#define ZMQ_SET_CLOSURE 41
- +#define ZMQ_GET_CLOSURE 42
- /* Message options */
- @@ -353,6 +355,12 @@
- ZMQ_EXPORT int zmq_sendmsg (void *s, zmq_msg_t *msg, int flags);
- ZMQ_EXPORT int zmq_recvmsg (void *s, zmq_msg_t *msg, int flags);
- +typedef struct {
- + const char * filter;
- + size_t size;
- + void *closure;
- +} zmq_closure_t;
- +
- /* Experimental */
- struct iovec;
Advertisement
Add Comment
Please, Sign In to add comment