Commit ea77f761 authored by Jakob Otto's avatar Jakob Otto

Remove unnecessary move, cleanup resolve

parent ff2dca97
...@@ -87,10 +87,10 @@ public: ...@@ -87,10 +87,10 @@ public:
emplace_return_type res; emplace_return_type res;
{ {
const std::lock_guard<std::mutex> lock(lock_); const std::lock_guard<std::mutex> lock(lock_);
res = peers_.emplace(peer_id, mgr); res = peers_.emplace(peer_id, std::move(mgr));
} }
if (res.second) if (res.second)
return std::move(mgr); return res.first->second;
else else
return make_error(sec::runtime_error, "peer_id already exists"); return make_error(sec::runtime_error, "peer_id already exists");
} }
......
...@@ -109,20 +109,10 @@ endpoint_manager_ptr tcp::peer(const node_id& id) { ...@@ -109,20 +109,10 @@ endpoint_manager_ptr tcp::peer(const node_id& id) {
} }
void tcp::resolve(const uri& locator, const actor& listener) { void tcp::resolve(const uri& locator, const actor& listener) {
if (auto id = locator.authority_only()) { if (auto p = get_or_connect(locator))
auto p = peer(make_node_id(*id)); (*p)->resolve(locator, listener);
if (p == nullptr) {
CAF_LOG_INFO("connecting to " << CAF_ARG(locator));
auto res = get_or_connect(locator);
if (!res)
anon_send(listener, error(sec::cannot_connect_to_node));
else else
p = *res; anon_send(listener, p.error());
}
p->resolve(locator, listener);
} else {
anon_send(listener, error(basp::ec::invalid_locator));
}
} }
strong_actor_ptr tcp::make_proxy(node_id nid, actor_id aid) { strong_actor_ptr tcp::make_proxy(node_id nid, actor_id aid) {
......
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