merged changes from RC_1_0

This commit is contained in:
Arvid Norberg 2014-08-22 07:56:10 +00:00
parent 07af6f6216
commit 862844e546
6 changed files with 51 additions and 10 deletions

View File

@ -27,6 +27,7 @@
* almost completely changed the storage interface (for custom storage) * almost completely changed the storage interface (for custom storage)
* added support for hashing pieces in multiple threads * added support for hashing pieces in multiple threads
* support IPv6 traffic class (via the TOS setting)
* made uTP re-enter slow-start after time-out * made uTP re-enter slow-start after time-out
* fixed uTP upload performance issue * fixed uTP upload performance issue
* fix missing support for DHT put salt * fix missing support for DHT put salt

View File

@ -1162,6 +1162,8 @@ int main(int argc, char* argv[])
// if there's a flag but no argument following, ignore it // if there's a flag but no argument following, ignore it
if (argc == i) continue; if (argc == i) continue;
char const* arg = argv[i+1]; char const* arg = argv[i+1];
if (arg == NULL) arg = "";
switch (argv[i][1]) switch (argv[i][1])
{ {
case 'f': g_log_file = fopen(arg, "w+"); break; case 'f': g_log_file = fopen(arg, "w+"); break;

View File

@ -135,6 +135,20 @@ namespace libtorrent
}; };
#endif #endif
struct traffic_class
{
traffic_class(char val): m_value(val) {}
template<class Protocol>
int level(Protocol const&) const { return IPPROTO_IPV6; }
template<class Protocol>
int name(Protocol const&) const { return IPV6_TCLASS; }
template<class Protocol>
int const* data(Protocol const&) const { return &m_value; }
template<class Protocol>
size_t size(Protocol const&) const { return sizeof(m_value); }
int m_value;
};
struct type_of_service struct type_of_service
{ {
#ifdef WIN32 #ifdef WIN32

View File

@ -520,6 +520,12 @@ namespace libtorrent
peer_log(">>> SET_TOS[ tos: %d e: %s ]", m_settings.get_int(settings_pack::peer_tos), ec.message().c_str()); peer_log(">>> SET_TOS[ tos: %d e: %s ]", m_settings.get_int(settings_pack::peer_tos), ec.message().c_str());
#endif #endif
} }
#if TORRENT_USE_IPV6
else if (m_remote.address().is_v6() && m_settings.get_int(settings_pack::peer_tos) != 0)
{
m_socket->set_option(traffic_class(m_settings.get_int(settings_pack::peer_tos)), ec);
}
#endif
} }
#if defined TORRENT_VERBOSE_LOGGING #if defined TORRENT_VERBOSE_LOGGING
@ -6368,6 +6374,12 @@ namespace libtorrent
peer_log(">>> SET_TOS[ tos: %d e: %s ]", m_settings.get_int(settings_pack::peer_tos), ec.message().c_str()); peer_log(">>> SET_TOS[ tos: %d e: %s ]", m_settings.get_int(settings_pack::peer_tos), ec.message().c_str());
#endif #endif
} }
#if TORRENT_USE_IPV6
else if (m_remote.address().is_v6() && m_settings.get_int(settings_pack::peer_tos) != 0)
{
m_socket->set_option(traffic_class(m_settings.get_int(settings_pack::peer_tos)), ec);
}
#endif
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
for (extension_list_t::iterator i = m_extensions.begin() for (extension_list_t::iterator i = m_extensions.begin()

View File

@ -2597,12 +2597,9 @@ retry:
} }
if (m_settings.get_int(settings_pack::peer_tos) != 0) { if (m_settings.get_int(settings_pack::peer_tos) != 0) {
m_udp_socket.set_option(type_of_service(m_settings.get_int(settings_pack::peer_tos)), ec); update_peer_tos();
#if defined TORRENT_VERBOSE_LOGGING
session_log(">>> SET_TOS[ udp_socket tos: %x e: %s ]"
, m_settings.get_int(settings_pack::peer_tos), ec.message().c_str());
#endif
} }
ec.clear(); ec.clear();
set_socket_buffer_size(m_udp_socket, m_settings, ec); set_socket_buffer_size(m_udp_socket, m_settings, ec);
@ -7034,9 +7031,16 @@ retry:
void session_impl::update_peer_tos() void session_impl::update_peer_tos()
{ {
error_code ec; error_code ec;
#if TORRENT_USE_IPV6
if (m_udp_socket.local_endpoint(ec).address().is_v6())
m_udp_socket.set_option(traffic_class(m_settings.get_int(settings_pack::peer_tos)), ec);
else
#endif
m_udp_socket.set_option(type_of_service(m_settings.get_int(settings_pack::peer_tos)), ec); m_udp_socket.set_option(type_of_service(m_settings.get_int(settings_pack::peer_tos)), ec);
#if defined TORRENT_VERBOSE_LOGGING #if defined TORRENT_VERBOSE_LOGGING
session_log(">>> SET_TOS[ udp_socket tos: %x e: %s ]" session_log(">>> SET_TOS [ udp_socket tos: %x e: %s ]"
, m_settings.get_int(settings_pack::peer_tos) , m_settings.get_int(settings_pack::peer_tos)
, ec.message().c_str()); , ec.message().c_str());
#endif #endif

View File

@ -93,17 +93,25 @@ int test_main()
std::vector<udp::endpoint> list; std::vector<udp::endpoint> list;
read_endpoint_list<udp::endpoint>(&e, list); read_endpoint_list<udp::endpoint>(&e, list);
#if TORRENT_USE_IPV6
TEST_EQUAL(list.size(), 2); TEST_EQUAL(list.size(), 2);
TEST_EQUAL(list[0], udp::endpoint(address_v4::from_string("16.5.128.1"), 1337));
TEST_EQUAL(list[1], udp::endpoint(address_v6::from_string("1000::ffff"), 1337)); TEST_EQUAL(list[1], udp::endpoint(address_v6::from_string("1000::ffff"), 1337));
#else
TEST_EQUAL(list.size(), 1);
#endif
TEST_EQUAL(list[0], udp::endpoint(address_v4::from_string("16.5.128.1"), 1337));
entry e2 = bdecode(eplist, eplist + sizeof(eplist)-1); entry e2 = bdecode(eplist, eplist + sizeof(eplist)-1);
list.clear(); list.clear();
read_endpoint_list<udp::endpoint>(&e2, list); read_endpoint_list<udp::endpoint>(&e2, list);
#if TORRENT_USE_IPV6
TEST_EQUAL(list.size(), 2); TEST_EQUAL(list.size(), 2);
TEST_EQUAL(list[0], udp::endpoint(address_v4::from_string("16.5.128.1"), 1337));
TEST_EQUAL(list[1], udp::endpoint(address_v6::from_string("1000::ffff"), 1337)); TEST_EQUAL(list[1], udp::endpoint(address_v6::from_string("1000::ffff"), 1337));
#else
TEST_EQUAL(list.size(), 1);
#endif
TEST_EQUAL(list[0], udp::endpoint(address_v4::from_string("16.5.128.1"), 1337));
return 0; return 0;
} }