From 4d17e0132e67b237ec4d30a513af6c62d0bc954a Mon Sep 17 00:00:00 2001 From: arvidn Date: Wed, 25 Apr 2018 12:31:02 -0400 Subject: [PATCH] fix empty outgoing interfaces for UDP sockets --- include/libtorrent/aux_/session_udp_sockets.hpp | 3 ++- src/session_impl.cpp | 4 ++-- src/session_udp_sockets.cpp | 10 ++++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/include/libtorrent/aux_/session_udp_sockets.hpp b/include/libtorrent/aux_/session_udp_sockets.hpp index b751382c4..5bc5959d2 100644 --- a/include/libtorrent/aux_/session_udp_sockets.hpp +++ b/include/libtorrent/aux_/session_udp_sockets.hpp @@ -89,7 +89,8 @@ namespace libtorrent { namespace aux { std::vector>::iterator partition_outgoing_sockets(std::vector& 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); diff --git a/src/session_impl.cpp b/src/session_impl.cpp index fbeec2100..f85087bca 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -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; } diff --git a/src/session_udp_sockets.cpp b/src/session_udp_sockets.cpp index 8ec281e34..2a63f1e43 100644 --- a/src/session_udp_sockets.cpp +++ b/src/session_udp_sockets.cpp @@ -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;