merged utp performance fix from RC_0_16

This commit is contained in:
Arvid Norberg 2012-11-08 09:16:40 +00:00
parent 65e02c23e8
commit 99e3fbaed5
2 changed files with 13 additions and 8 deletions

View File

@ -122,11 +122,11 @@ namespace libtorrent
// this is a copy of the routing table, used
// to initialize MTU sizes of uTP sockets
std::vector<ip_route> m_routes;
mutable std::vector<ip_route> m_routes;
// the timestamp for the last time we updated
// the routing table
ptime m_last_route_update;
mutable ptime m_last_route_update;
// the buffer size of the socket. This is used
// to now lower the buffer size

View File

@ -204,14 +204,19 @@ namespace libtorrent
tcp::endpoint socket_ep = m_sock.local_endpoint(ec);
// first enumerate the routes in the routing table
std::vector<ip_route> routes = enum_routes(m_sock.get_io_service(), ec);
if (ec) return socket_ep;
if (time_now() - m_last_route_update > seconds(60))
{
m_last_route_update = time_now();
error_code ec;
m_routes = enum_routes(m_sock.get_io_service(), ec);
if (ec) return socket_ep;
}
if (routes.empty()) return socket_ep;
if (m_routes.empty()) return socket_ep;
// then find the best match
ip_route* best = &routes[0];
for (std::vector<ip_route>::iterator i = routes.begin()
, end(routes.end()); i != end; ++i)
ip_route* best = &m_routes[0];
for (std::vector<ip_route>::iterator i = m_routes.begin()
, end(m_routes.end()); i != end; ++i)
{
if (is_any(i->destination) && i->destination.is_v4() == remote.is_v4())
{