don't attempt to make uTP connections if we don't have any outgoing UDP sockets

This commit is contained in:
arvidn 2018-05-10 18:58:29 +02:00 committed by Arvid Norberg
parent 4d17e0132e
commit ddd1168296
4 changed files with 11 additions and 1 deletions

View File

@ -691,6 +691,7 @@ namespace aux {
mutable std::condition_variable cond;
// implements session_interface
bool has_udp_outgoing_sockets() const override;
tcp::endpoint bind_outgoing_socket(socket_type& s, address
const& remote_address, error_code& ec) const override;
bool verify_incoming_interface(address const& addr);

View File

@ -211,6 +211,7 @@ namespace aux {
virtual void for_each_listen_socket(std::function<void(aux::listen_socket_handle const&)> f) = 0;
// ask for which interface and port to bind outgoing peer connections on
virtual bool has_udp_outgoing_sockets() const = 0;
virtual tcp::endpoint bind_outgoing_socket(socket_type& s, address const&
remote_address, error_code& ec) const = 0;
virtual bool verify_bound_address(address const& addr, bool utp

View File

@ -4964,6 +4964,11 @@ namespace aux {
#endif
}
bool session_impl::has_udp_outgoing_sockets() const
{
return !m_outgoing_sockets.sockets.empty();
}
tcp::endpoint session_impl::bind_outgoing_socket(socket_type& s, address
const& remote_address, error_code& ec) const
{

View File

@ -6563,8 +6563,11 @@ bool is_downloading_state(int const st)
if (settings().get_bool(settings_pack::enable_outgoing_utp)
&& (!settings().get_bool(settings_pack::enable_outgoing_tcp)
|| peerinfo->supports_utp
|| peerinfo->confirmed_supports_utp))
|| peerinfo->confirmed_supports_utp)
&& m_ses.has_udp_outgoing_sockets())
{
sm = m_ses.utp_socket_manager();
}
// don't make a TCP connection if it's disabled
if (sm == nullptr && !settings().get_bool(settings_pack::enable_outgoing_tcp))