merged utp_socket_manager optimization from libtorrent_aio
This commit is contained in:
parent
58d5b9aedc
commit
5b26d5d962
|
@ -1033,6 +1033,7 @@ namespace libtorrent
|
|||
};
|
||||
|
||||
// this list is sorted by time_critical_piece::deadline
|
||||
// TODO: this should be a deque
|
||||
std::list<time_critical_piece> m_time_critical_pieces;
|
||||
|
||||
std::string m_trackerid;
|
||||
|
|
|
@ -128,6 +128,10 @@ namespace libtorrent
|
|||
// the routing table
|
||||
mutable ptime m_last_route_update;
|
||||
|
||||
// cache of interfaces
|
||||
mutable std::vector<ip_interface> m_interfaces;
|
||||
mutable ptime m_last_if_update;
|
||||
|
||||
// the buffer size of the socket. This is used
|
||||
// to now lower the buffer size
|
||||
int m_sock_buf_size;
|
||||
|
|
|
@ -51,6 +51,7 @@ namespace libtorrent
|
|||
, m_new_connection(-1)
|
||||
, m_sett(sett)
|
||||
, m_last_route_update(min_time())
|
||||
, m_last_if_update(min_time())
|
||||
, m_sock_buf_size(0)
|
||||
{}
|
||||
|
||||
|
@ -235,11 +236,16 @@ namespace libtorrent
|
|||
// for this target. Now figure out what the local address
|
||||
// is for that interface
|
||||
|
||||
std::vector<ip_interface> net = enum_net_interfaces(m_sock.get_io_service(), ec);
|
||||
if (time_now() - m_last_if_update > seconds(60))
|
||||
{
|
||||
m_last_if_update = time_now();
|
||||
error_code ec;
|
||||
m_interfaces = enum_net_interfaces(m_sock.get_io_service(), ec);
|
||||
if (ec) return socket_ep;
|
||||
}
|
||||
|
||||
for (std::vector<ip_interface>::iterator i = net.begin()
|
||||
, end(net.end()); i != end; ++i)
|
||||
for (std::vector<ip_interface>::iterator i = m_interfaces.begin()
|
||||
, end(m_interfaces.end()); i != end; ++i)
|
||||
{
|
||||
if (i->interface_address.is_v4() != remote.is_v4())
|
||||
continue;
|
||||
|
|
Loading…
Reference in New Issue