Commit 1d93cf63 authored by Joseph Noir's avatar Joseph Noir

Add test for autoconnect and fix related bugs

parent a287b288
......@@ -337,7 +337,8 @@ public:
return false;
}
// Close this connection if we already established communication.
if (tbl_.lookup(hdr.source_node).hdl) {
auto lr = tbl_.lookup(hdr.source_node);
if (lr.hdl) {
CAF_LOG_INFO("close connection since we already have a "
"connection: " << CAF_ARG(hdr.source_node));
callee_.finalize_handshake(hdr.source_node, aid, sigs);
......@@ -345,7 +346,10 @@ public:
}
// Add this node to our contacts.
CAF_LOG_INFO("new endpoint:" << CAF_ARG(hdr.source_node));
tbl_.add(hdr.source_node, hdl);
if (lr.known)
tbl_.handle(hdr.source_node, hdl);
else
tbl_.add(hdr.source_node, hdl);
auto config_server = system().registry().get(atom("ConfigServ"));
anon_send(actor_cast<actor>(config_server), put_atom::value,
to_string(hdr.source_node), make_message(addrs));
......
......@@ -97,6 +97,11 @@ strong_actor_ptr basp_broker_state::make_proxy(node_id nid, actor_id aid) {
// payload received from a remote node; if a remote node A sends
// us a handle to a third node B, then we assume that A can tell us
// how to contact B.
// TODO: This should probably happen somewhere else, but is usually only
// performed in `finalize_handshake` which is only called on receipt
// of server handshakes.
if (this_context->id == none)
this_context->id = instance.tbl().lookup(this_context->hdl);
auto lr = instance.tbl().lookup(nid);
if (nid != this_context->id && !lr.known) {
instance.tbl().add(nid, this_context->id);
......@@ -414,7 +419,6 @@ void basp_broker_state::establish_communication(const node_id& nid) {
// TODO: Split this by functionality, address query & connecting?
CAF_ASSERT(this_context != nullptr);
CAF_LOG_TRACE(CAF_ARG(nid));
learned_new_node(nid);
if (!enable_automatic_connections)
return;
// this member function gets only called once, after adding a new
......@@ -452,7 +456,7 @@ void basp_broker_state::establish_communication(const node_id& nid) {
});
basp::header hdr{basp::message_type::dispatch_message,
basp::header::named_receiver_flag,
0, 0, this_node(), nid, tmp.id(), invalid_actor_id,
0, 0, this_node(), *origin, tmp.id(), invalid_actor_id,
visit(seq_num_visitor{this}, hdl)};
instance.write(self->context(), get_buffer(hdl),
hdr, &writer);
......@@ -669,7 +673,7 @@ basp_broker_state::get_buffer(node_id nid) {
if (res.known && res.hdl) {
return get_buffer(*res.hdl);
}
auto msgs = pending_connectivity[nid];
auto& msgs = pending_connectivity[nid];
msgs.emplace_back();
return msgs.back();
}
......
......@@ -108,6 +108,7 @@ bool routing_table::handle(const node_id& nid,
if (i == node_information_base_.end())
return false;
i->second.hdl = hdl;
nid_by_hdl_.emplace(hdl, nid);
return true;
}
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment