diff --git a/ChangeLog b/ChangeLog index e96d5323a..db3d17e8b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -84,12 +84,14 @@ * resume data no longer has timestamps of files * require C++11 to build libtorrent + * fix recent regression with force_proxy setting * don't perform DNS lookups for the DHT bootstrap unless DHT is enabled * fix issue where setting file/piece priority would stop checking * expose post_dht_stats() to python binding * fix backwards compatibility to downloads without partfiles * improve part-file related error messages * fix reporting &redundant= in tracker announces + * fix tracker announces reporting more data downloaded than the size of the torrent * fix tie-break in duplicate peer connection disconnect logic * fix issue with SSL tracker connections left in CLOSE_WAIT state * defer truncating existing files until the first time we write to them diff --git a/src/torrent.cpp b/src/torrent.cpp index b838d6ab0..09ebac37e 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -2745,10 +2745,34 @@ bool is_downloading_state(int const st) req.ssl_ctx = m_ssl_ctx.get(); #endif + req.redundant = m_total_redundant_bytes; // exclude redundant bytes if we should if (!settings().get_bool(settings_pack::report_true_downloaded)) + { req.downloaded -= m_total_redundant_bytes; - req.redundant = m_total_redundant_bytes; + + // if the torrent is complete we know that all incoming pieces will be + // marked redundant so add them to the redundant count + // this is mainly needed to cover the case where a torrent has just completed + // but still has partially downloaded pieces + // if the incoming pieces are not accounted for it could cause the downloaded + // amount to exceed the total size of the torrent which upsets some trackers + if (is_seed()) + { + for (peer_iterator i = m_connections.begin(); + i != m_connections.end(); ++i) + { + TORRENT_INCREMENT(m_iterating_connections); + peer_connection* p = *i; + boost::optional pbp = p->downloading_piece_progress(); + if (pbp && pbp->bytes_downloaded > 0) + { + req.downloaded -= pbp->bytes_downloaded; + req.redundant += pbp->bytes_downloaded; + } + } + } + } if (req.downloaded < 0) req.downloaded = 0; req.event = e;