Skip to content

Commit

Permalink
[FREELAN] When switch mode is used, avoid to relay to same host as so…
Browse files Browse the repository at this point in the history
…urce.
  • Loading branch information
s-vincent committed Dec 16, 2018
1 parent f499f9a commit 5742340
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
15 changes: 15 additions & 0 deletions libs/freelan/include/freelan/port_index.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ namespace freelan
return true;
}

friend bool operator!=(const null_port_index_type&, const null_port_index_type&)
{
return false;
}

friend std::ostream& operator<<(std::ostream& os, const null_port_index_type&)
{
return os << "null()";
Expand Down Expand Up @@ -124,6 +129,11 @@ namespace freelan
return (lhs.m_tap_adapter == rhs.m_tap_adapter);
}

friend bool operator!=(const tap_adapter_port_index_type& lhs, const tap_adapter_port_index_type& rhs)
{
return !(lhs.m_tap_adapter == rhs.m_tap_adapter);
}

friend std::ostream& operator<<(std::ostream& os, const tap_adapter_port_index_type& idx)
{
return os << "tap_adapter(" << *idx.m_tap_adapter << ")";
Expand Down Expand Up @@ -161,6 +171,11 @@ namespace freelan
return (lhs.m_ep == rhs.m_ep);
}

friend bool operator!=(const endpoint_port_index_type& lhs, const endpoint_port_index_type& rhs)
{
return !(lhs.m_ep == rhs.m_ep);
}

friend std::ostream& operator<<(std::ostream& os, const endpoint_port_index_type& idx)
{
return os << "endpoint(" << idx.m_ep << ")";
Expand Down
11 changes: 10 additions & 1 deletion libs/freelan/src/switch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,16 @@ namespace freelan
std::cerr << index << "-> " << target << std::endl;
#endif

m_ports[target].async_write(data, boost::bind(&results_gatherer_type::gather, rg, target, _1));
if(index != target)
{
m_ports[target].async_write(data, boost::bind(&results_gatherer_type::gather, rg, target, _1));
}
#if FREELAN_DEBUG
else
{
std::cerr << "Index matching target forbidden (" << index << "-> " << target << ")" << std::endl;
}
#endif
}
}

Expand Down

0 comments on commit 5742340

Please sign in to comment.