Commit 0a321cf9 authored by Dominik Charousset's avatar Dominik Charousset

Fix issue with multiple connections to same node

parent ad651cd3
...@@ -414,15 +414,19 @@ basp_broker::handle_basp_header(connection_context& ctx, ...@@ -414,15 +414,19 @@ basp_broker::handle_basp_header(connection_context& ctx,
} }
auto& ifs = *(ctx.handshake_data->expected_ifs); auto& ifs = *(ctx.handshake_data->expected_ifs);
if (!std::includes(ifs.begin(), ifs.end(), if (!std::includes(ifs.begin(), ifs.end(),
remote_ifs.begin(), remote_ifs.end())) { remote_ifs.begin(), remote_ifs.end())) {
auto tostr = [](const std::set<string>& what) -> string { auto tostr = [](const std::set<string>& what) -> string {
if (what.empty()) return "actor"; if (what.empty()) {
return "actor";
}
string tmp; string tmp;
tmp = "typed_actor<"; tmp = "typed_actor<";
auto i = what.begin(); auto i = what.begin();
auto e = what.end(); auto e = what.end();
tmp += *i++; tmp += *i++;
while (i != e) tmp += *i++; while (i != e) {
tmp += *i++;
}
tmp += ">"; tmp += ">";
return tmp; return tmp;
}; };
...@@ -431,21 +435,21 @@ basp_broker::handle_basp_header(connection_context& ctx, ...@@ -431,21 +435,21 @@ basp_broker::handle_basp_header(connection_context& ctx,
auto& error_msg = *(ctx.handshake_data->error_msg); auto& error_msg = *(ctx.handshake_data->error_msg);
if (ifs.empty()) { if (ifs.empty()) {
error_msg = "expected remote actor to be a " error_msg = "expected remote actor to be a "
"dynamically typed actor but found " "dynamically typed actor but found "
"a strongly typed actor of type " "a strongly typed actor of type "
+ iface_str; + iface_str;
} }
else if (remote_ifs.empty()) { else if (remote_ifs.empty()) {
error_msg = "expected remote actor to be a " error_msg = "expected remote actor to be a "
"strongly typed actor of type " "strongly typed actor of type "
+ expected_str + + expected_str +
" but found a dynamically typed actor"; " but found a dynamically typed actor";
} else { } else {
error_msg = "expected remote actor to be a " error_msg = "expected remote actor to be a "
"strongly typed actor of type " "strongly typed actor of type "
+ expected_str + + expected_str +
" but found a strongly typed actor of type " " but found a strongly typed actor of type "
+ iface_str; + iface_str;
} }
// abort with error // abort with error
ctx.handshake_data->result->set_value(nullptr); ctx.handshake_data->result->set_value(nullptr);
...@@ -460,13 +464,9 @@ basp_broker::handle_basp_header(connection_context& ctx, ...@@ -460,13 +464,9 @@ basp_broker::handle_basp_header(connection_context& ctx,
return close_connection; return close_connection;
} }
if (!try_set_default_route(nid, ctx.hdl)) { if (!try_set_default_route(nid, ctx.hdl)) {
CAF_LOG_INFO("multiple connections to " CAF_LOG_INFO("multiple connections to " << to_string(nid)
<< to_string(nid) << " (re-use old one)");
<< " (re-use old one)"); auto proxy = m_namespace.get_or_put(nid, remote_aid);
auto proxy = m_namespace.get(nid, remote_aid);
CAF_LOG_INFO_IF(!proxy,
"no proxy for published actor found "
"although an open connection exists");
// discard this peer; there's already an open connection // discard this peer; there's already an open connection
ctx.handshake_data->result->set_value(std::move(proxy)); ctx.handshake_data->result->set_value(std::move(proxy));
ctx.handshake_data = nullptr; ctx.handshake_data = nullptr;
...@@ -476,8 +476,8 @@ basp_broker::handle_basp_header(connection_context& ctx, ...@@ -476,8 +476,8 @@ basp_broker::handle_basp_header(connection_context& ctx,
auto& buf = wr_buf(ctx.hdl); auto& buf = wr_buf(ctx.hdl);
binary_serializer bs(std::back_inserter(buf), &m_namespace); binary_serializer bs(std::back_inserter(buf), &m_namespace);
write(bs, {node(), ctx.handshake_data->remote_id, write(bs, {node(), ctx.handshake_data->remote_id,
invalid_actor_id, invalid_actor_id, invalid_actor_id, invalid_actor_id,
0, basp::client_handshake, 0}); 0, basp::client_handshake, 0});
// prepare to receive messages // prepare to receive messages
auto proxy = m_namespace.get_or_put(nid, remote_aid); auto proxy = m_namespace.get_or_put(nid, remote_aid);
ctx.published_actor = proxy; ctx.published_actor = proxy;
......
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