problem: zeromq connects peer before handshake is completed

Solution: delay connecting the peer pipe until the handshake is completed
This commit is contained in:
Doron Somech
2020-05-13 17:32:06 +03:00
parent 18cacf2ec1
commit e7f0090b16
13 changed files with 47 additions and 14 deletions

View File

@@ -407,7 +407,18 @@ bool zmq::session_base_t::zap_enabled () const
void zmq::session_base_t::process_attach (i_engine *engine_)
{
zmq_assert (engine_ != NULL);
zmq_assert (!_engine);
_engine = engine_;
if (!engine_->has_handshake_stage ())
engine_ready ();
// Plug in the engine.
_engine->plug (_io_thread, this);
}
void zmq::session_base_t::engine_ready ()
{
// Create the pipe if it does not exist yet.
if (!_pipe && !is_terminating ()) {
object_t *parents[2] = {this, _socket};
@@ -430,17 +441,12 @@ void zmq::session_base_t::process_attach (i_engine *engine_)
// The endpoints strings are not set on bind, set them here so that
// events can use them.
pipes[0]->set_endpoint_pair (engine_->get_endpoint ());
pipes[1]->set_endpoint_pair (engine_->get_endpoint ());
pipes[0]->set_endpoint_pair (_engine->get_endpoint ());
pipes[1]->set_endpoint_pair (_engine->get_endpoint ());
// Ask socket to plug into the remote end of the pipe.
send_bind (_socket, pipes[1]);
}
// Plug in the engine.
zmq_assert (!_engine);
_engine = engine_;
_engine->plug (_io_thread, this);
}
void zmq::session_base_t::engine_error (bool handshaked_,