diff --git a/ChangeLog b/ChangeLog index 53bd57729..a0ae498cd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -79,6 +79,7 @@ 1.1.5 release + * fix uTP path MTU discovery issue on windows (DF bit was not set correctly) * fix python binding for torrent_handle, to be hashable * fix IPv6 tracker support by performing the second announce in more cases * fix utf-8 encoding check in torrent parser diff --git a/include/libtorrent/alert_types.hpp b/include/libtorrent/alert_types.hpp index b6ca16227..932691a36 100644 --- a/include/libtorrent/alert_types.hpp +++ b/include/libtorrent/alert_types.hpp @@ -897,10 +897,11 @@ namespace libtorrent { piece_index_t const piece_index; }; - // The ``storage_moved_alert`` is generated when all the disk IO has completed and the - // files have been moved, as an effect of a call to ``torrent_handle::move_storage``. This - // is useful to synchronize with the actual disk. The ``path`` member is the new path of - // the storage. + // The ``storage_moved_alert`` is generated when all the disk IO has + // completed and the files have been moved, as an effect of a call to + // ``torrent_handle::move_storage``. This is useful to synchronize with the + // actual disk. The ``storage_path()`` member return the new path of the + // storage. struct TORRENT_EXPORT storage_moved_alert final : torrent_alert { // internal diff --git a/include/libtorrent/socket.hpp b/include/libtorrent/socket.hpp index e522137aa..00ecb203d 100644 --- a/include/libtorrent/socket.hpp +++ b/include/libtorrent/socket.hpp @@ -160,26 +160,24 @@ namespace libtorrent { #endif #ifdef TORRENT_HAS_DONT_FRAGMENT + + // the order of these preprocessor tests matters. Windows defines both + // IP_DONTFRAGMENT and IP_MTU_DISCOVER, but the latter is not supported + // in general, the simple option of just setting the DF bit is preferred, if + // it's available +#if defined IP_DONTFRAG || defined IP_DONTFRAGMENT + struct dont_fragment { - explicit dont_fragment(bool val) -#ifdef IP_PMTUDISCOVER_DO - : m_value(val ? IP_PMTUDISC_DO : IP_PMTUDISC_DONT) {} -#else - : m_value(val) {} -#endif + explicit dont_fragment(bool val) : m_value(val) {} template int level(Protocol const&) const { return IPPROTO_IP; } template int name(Protocol const&) const #if defined IP_DONTFRAG { return IP_DONTFRAG; } -#elif defined IP_MTU_DISCOVER - { return IP_MTU_DISCOVER; } -#elif defined IP_DONTFRAGMENT +#else // defined IP_DONTFRAGMENT { return IP_DONTFRAGMENT; } -#else - {} #endif template int const* data(Protocol const&) const { return &m_value; } @@ -187,6 +185,30 @@ namespace libtorrent { size_t size(Protocol const&) const { return sizeof(m_value); } int m_value; }; + +#else + + // this is the fallback mechanism using the IP_MTU_DISCOVER option, which + // does a little bit more than we want, it makes the kernel track an estimate + // of the MTU and rejects packets immediately if they are believed to exceed + // it. + struct dont_fragment + { + explicit dont_fragment(bool val) + : m_value(val ? IP_PMTUDISC_DO : IP_PMTUDISC_DONT) {} + template + int level(Protocol const&) const { return IPPROTO_IP; } + template + int name(Protocol const&) const { return IP_MTU_DISCOVER; } + template + int const* data(Protocol const&) const { return &m_value; } + template + size_t size(Protocol const&) const { return sizeof(m_value); } + int m_value; + }; + +#endif // IP_DONTFRAG vs. IP_MTU_DISCOVER + #endif // TORRENT_HAS_DONT_FRAGMENT }