Commit 822dc4d0 authored by Dominik Charousset's avatar Dominik Charousset

Remove unused blacklist from routing table

parent c42dcaf0
...@@ -73,9 +73,6 @@ public: ...@@ -73,9 +73,6 @@ public:
/// Adds a new indirect route to the table. /// Adds a new indirect route to the table.
bool add_indirect(const node_id& hop, const node_id& dest); bool add_indirect(const node_id& hop, const node_id& dest);
/// Blacklist the route to `dest` via `hop`.
void blacklist(const node_id& hop, const node_id& dest);
/// Removes a direct connection and calls `cb` for any node /// Removes a direct connection and calls `cb` for any node
/// that became unreachable as a result of this operation, /// that became unreachable as a result of this operation,
/// including the node that is assigned as direct path for `hdl`. /// including the node that is assigned as direct path for `hdl`.
...@@ -118,7 +115,6 @@ public: ...@@ -118,7 +115,6 @@ public:
std::unordered_map<connection_handle, node_id> direct_by_hdl_; std::unordered_map<connection_handle, node_id> direct_by_hdl_;
std::unordered_map<node_id, connection_handle> direct_by_nid_; std::unordered_map<node_id, connection_handle> direct_by_nid_;
indirect_entries indirect_; indirect_entries indirect_;
indirect_entries blacklist_;
}; };
/// @} /// @}
......
...@@ -68,19 +68,10 @@ strong_actor_ptr basp_broker_state::make_proxy(node_id nid, actor_id aid) { ...@@ -68,19 +68,10 @@ 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 // 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 offers a route to B // us a handle to a third node B, then we assume that A offers a route to B
if (nid != this_context->id if (nid != this_context->id
&& !instance.tbl().lookup_direct(nid)
&& instance.tbl().add_indirect(this_context->id, nid)) && instance.tbl().add_indirect(this_context->id, nid))
learned_new_node_indirectly(nid); learned_new_node_indirectly(nid);
// we need to tell remote side we are watching this actor now; // we need to tell remote side we are watching this actor now;
// use a direct route if possible, i.e., when talking to a third node // use a direct route if possible, i.e., when talking to a third node
auto path = instance.tbl().lookup(nid);
if (!path) {
// this happens if and only if we don't have a path to `nid`
// and current_context_->hdl has been blacklisted
CAF_LOG_DEBUG("cannot create a proxy instance for an actor "
"running on a node we don't have a route to");
return nullptr;
}
// create proxy and add functor that will be called if we // create proxy and add functor that will be called if we
// receive a basp::down_message // receive a basp::down_message
auto mm = &system().middleman(); auto mm = &system().middleman();
...@@ -105,7 +96,7 @@ strong_actor_ptr basp_broker_state::make_proxy(node_id nid, actor_id aid) { ...@@ -105,7 +96,7 @@ strong_actor_ptr basp_broker_state::make_proxy(node_id nid, actor_id aid) {
// tell remote side we are monitoring this actor now // tell remote side we are monitoring this actor now
instance.write_monitor_message(self->context(), get_buffer(this_context->hdl), instance.write_monitor_message(self->context(), get_buffer(this_context->hdl),
nid, aid); nid, aid);
instance.flush(*path); flush(this_context->hdl);
mm->notify<hook::new_remote_actor>(res); mm->notify<hook::new_remote_actor>(res);
return res; return res;
} }
......
...@@ -73,16 +73,6 @@ node_id routing_table::lookup_indirect(const node_id& nid) const { ...@@ -73,16 +73,6 @@ node_id routing_table::lookup_indirect(const node_id& nid) const {
return *i->second.begin(); return *i->second.begin();
} }
void routing_table::blacklist(const node_id& hop, const node_id& dest) {
blacklist_[dest].emplace(hop);
auto i = indirect_.find(dest);
if (i == indirect_.end())
return;
i->second.erase(hop);
if (i->second.empty())
indirect_.erase(i);
}
void routing_table::erase_direct(const connection_handle& hdl, void routing_table::erase_direct(const connection_handle& hdl,
erase_callback& cb) { erase_callback& cb) {
auto i = direct_by_hdl_.find(hdl); auto i = direct_by_hdl_.find(hdl);
...@@ -115,15 +105,17 @@ void routing_table::add_direct(const connection_handle& hdl, ...@@ -115,15 +105,17 @@ void routing_table::add_direct(const connection_handle& hdl,
} }
bool routing_table::add_indirect(const node_id& hop, const node_id& dest) { bool routing_table::add_indirect(const node_id& hop, const node_id& dest) {
auto i = blacklist_.find(dest); // Never add indirect entries if we already have direct connection.
if (i == blacklist_.end() || i->second.count(hop) == 0) { if (lookup_direct(dest) != none)
return false;
// Never add indirect entries if we don't have a connection to the hop.
if (lookup_direct(hop) == none)
return false;
auto& hops = indirect_[dest]; auto& hops = indirect_[dest];
auto added_first = hops.empty(); auto result = hops.empty();
hops.emplace(hop); if (hops.emplace(hop).second)
parent_->parent().notify<hook::new_route_added>(hop, dest); parent_->parent().notify<hook::new_route_added>(hop, dest);
return added_first; return result;
}
return false; // blacklisted
} }
bool routing_table::reachable(const node_id& dest) { bool routing_table::reachable(const node_id& dest) {
......
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