diff --git a/ChangeLog b/ChangeLog index 10c45d744..9ce57e22d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -105,6 +105,7 @@ 0.15.10 release + * fixed peer_tos (type of service) setting * fixed crash when loading resume file with more files than the torrent in it * fix invalid-parameter error on windows when disabling filesystem disk cache * fix connection queue issue causing shutdown delays diff --git a/include/libtorrent/socket.hpp b/include/libtorrent/socket.hpp index aeaa7e376..76b783c20 100644 --- a/include/libtorrent/socket.hpp +++ b/include/libtorrent/socket.hpp @@ -135,16 +135,21 @@ namespace libtorrent struct type_of_service { +#ifdef WIN32 + typedef DWORD tos_t; +#else + typedef int tos_t; +#endif type_of_service(char val): m_value(val) {} template int level(Protocol const&) const { return IPPROTO_IP; } template int name(Protocol const&) const { return IP_TOS; } template - char const* data(Protocol const&) const { return &m_value; } + tos_t const* data(Protocol const&) const { return &m_value; } template size_t size(Protocol const&) const { return sizeof(m_value); } - char m_value; + tos_t m_value; }; #if defined IP_DONTFRAG || defined IP_MTU_DISCOVER || defined IP_DONTFRAGMENT diff --git a/src/session_impl.cpp b/src/session_impl.cpp index bc681b1e6..5bcbfc248 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -1926,6 +1926,15 @@ namespace aux { if (m_settings.dht_upload_rate_limit != s.dht_upload_rate_limit) m_udp_socket.set_rate_limit(s.dht_upload_rate_limit); + if (m_settings.peer_tos != s.peer_tos) + { + error_code ec; + m_udp_socket.set_option(type_of_service(s.peer_tos), ec); +#if defined TORRENT_VERBOSE_LOGGING + (*m_logger) << ">>> SET_TOS[ udp_socket tos: " << s.peer_tos << " e: " << ec.message() << " ]\n"; +#endif + } + m_settings = s; if (m_settings.cache_buffer_chunk_size <= 0) @@ -2237,6 +2246,12 @@ namespace aux { maybe_update_udp_mapping(1, m_listen_interface.port(), m_listen_interface.port()); } + m_udp_socket.set_option(type_of_service(m_settings.peer_tos), ec); +#if defined TORRENT_VERBOSE_LOGGING + (*m_logger) << ">>> SET_TOS[ udp_socket tos: " << m_settings.peer_tos << " e: " << ec.message() << " ]\n"; +#endif + ec.clear(); + open_new_incoming_socks_connection(); #if TORRENT_USE_I2P open_new_incoming_i2p_connection();