Problem: ZMQ_CONNECT_ROUTING_ID can be assigned to incoming socket connection (Issue #3191)

Solution: Add an identifier parameter for local attach to zmq::socket_base_t::attach_pipe
This commit is contained in:
Michael Vilim
2018-07-24 13:48:43 -05:00
parent cc4d03fa1c
commit 8a16fef3cc
35 changed files with 241 additions and 51 deletions

View File

@@ -341,14 +341,16 @@ int zmq::socket_base_t::check_protocol (const std::string &protocol_)
return 0;
}
void zmq::socket_base_t::attach_pipe (pipe_t *pipe_, bool subscribe_to_all_)
void zmq::socket_base_t::attach_pipe (pipe_t *pipe_,
bool subscribe_to_all_,
bool locally_initiated_)
{
// First, register the pipe so that we can terminate it later on.
pipe_->set_event_sink (this);
_pipes.push_back (pipe_);
// Let the derived socket type know about new pipe.
xattach_pipe (pipe_, subscribe_to_all_);
xattach_pipe (pipe_, subscribe_to_all_, locally_initiated_);
// If the socket is already being closed, ask any new pipes to terminate
// straight away.
@@ -553,7 +555,7 @@ int zmq::socket_base_t::bind (const char *addr_)
errno_assert (rc == 0);
// Attach local end of the pipe to the socket object.
attach_pipe (new_pipes[0], true);
attach_pipe (new_pipes[0], true, true);
newpipe = new_pipes[0];
// Attach remote end of the pipe to the session object later on.
@@ -773,7 +775,7 @@ int zmq::socket_base_t::connect (const char *addr_)
}
// Attach local end of the pipe to this socket object.
attach_pipe (new_pipes[0]);
attach_pipe (new_pipes[0], false, true);
// Save last endpoint URI
_last_endpoint.assign (addr_);
@@ -959,7 +961,7 @@ int zmq::socket_base_t::connect (const char *addr_)
errno_assert (rc == 0);
// Attach local end of the pipe to the socket object.
attach_pipe (new_pipes[0], subscribe_to_all);
attach_pipe (new_pipes[0], subscribe_to_all, true);
newpipe = new_pipes[0];
// Attach remote end of the pipe to the session object later on.
@@ -1809,6 +1811,11 @@ std::string zmq::routing_socket_base_t::extract_connect_routing_id ()
return res;
}
bool zmq::routing_socket_base_t::connect_routing_id_is_set ()
{
return !_connect_routing_id.empty ();
}
void zmq::routing_socket_base_t::add_out_pipe (blob_t routing_id_,
pipe_t *pipe_)
{