merged utp performance fix from RC_0_16
This commit is contained in:
parent
65e02c23e8
commit
99e3fbaed5
|
@ -122,11 +122,11 @@ namespace libtorrent
|
||||||
|
|
||||||
// this is a copy of the routing table, used
|
// this is a copy of the routing table, used
|
||||||
// to initialize MTU sizes of uTP sockets
|
// 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 timestamp for the last time we updated
|
||||||
// the routing table
|
// the routing table
|
||||||
ptime m_last_route_update;
|
mutable ptime m_last_route_update;
|
||||||
|
|
||||||
// the buffer size of the socket. This is used
|
// the buffer size of the socket. This is used
|
||||||
// to now lower the buffer size
|
// to now lower the buffer size
|
||||||
|
|
|
@ -204,14 +204,19 @@ namespace libtorrent
|
||||||
tcp::endpoint socket_ep = m_sock.local_endpoint(ec);
|
tcp::endpoint socket_ep = m_sock.local_endpoint(ec);
|
||||||
|
|
||||||
// first enumerate the routes in the routing table
|
// first enumerate the routes in the routing table
|
||||||
std::vector<ip_route> routes = enum_routes(m_sock.get_io_service(), ec);
|
if (time_now() - m_last_route_update > seconds(60))
|
||||||
if (ec) return socket_ep;
|
{
|
||||||
|
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
|
// then find the best match
|
||||||
ip_route* best = &routes[0];
|
ip_route* best = &m_routes[0];
|
||||||
for (std::vector<ip_route>::iterator i = routes.begin()
|
for (std::vector<ip_route>::iterator i = m_routes.begin()
|
||||||
, end(routes.end()); i != end; ++i)
|
, end(m_routes.end()); i != end; ++i)
|
||||||
{
|
{
|
||||||
if (is_any(i->destination) && i->destination.is_v4() == remote.is_v4())
|
if (is_any(i->destination) && i->destination.is_v4() == remote.is_v4())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue