fix empty outgoing interfaces for UDP sockets

This commit is contained in:
arvidn 2018-04-25 12:31:02 -04:00 committed by Arvid Norberg
parent c98b700d4f
commit 4d17e0132e
3 changed files with 12 additions and 5 deletions

View File

@ -89,7 +89,8 @@ namespace libtorrent { namespace aux {
std::vector<std::shared_ptr<outgoing_udp_socket>>::iterator
partition_outgoing_sockets(std::vector<listen_endpoint_t>& eps);
tcp::endpoint bind(socket_type& s, address const& remote_address) const;
tcp::endpoint bind(socket_type& s, address const& remote_address
, error_code& ec) const;
void update_proxy(proxy_settings const& settings);

View File

@ -4988,8 +4988,8 @@ namespace aux {
if (is_utp(s))
{
auto ep = m_outgoing_sockets.bind(s, remote_address);
if (ep.port() != 0)
auto ep = m_outgoing_sockets.bind(s, remote_address, ec);
if (ep.port() != 0 || ec)
return ep;
}

View File

@ -32,6 +32,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/aux_/session_udp_sockets.hpp"
#include "libtorrent/aux_/session_impl.hpp"
#include "libtorrent/error_code.hpp"
namespace libtorrent { namespace aux {
@ -63,9 +64,14 @@ namespace libtorrent { namespace aux {
});
}
tcp::endpoint outgoing_sockets::bind(socket_type& s, address const& remote_address) const
tcp::endpoint outgoing_sockets::bind(socket_type& s
, address const& remote_address, error_code& ec) const
{
TORRENT_ASSERT(!sockets.empty());
if (sockets.empty())
{
ec.assign(boost::system::errc::not_supported, generic_category());
return tcp::endpoint();
}
utp_socket_impl* impl = nullptr;
transport ssl = transport::plaintext;