forked from premiere/premiere-libtorrent
reports redundant downloads to tracker, fixed downloaded calculation to be more stable when not including redundant. Improved redundant data accounting to be more accurate
This commit is contained in:
parent
973a1c45f2
commit
eba657d8ad
|
@ -53,6 +53,9 @@
|
|||
* added more detailed instrumentation of the disk I/O thread
|
||||
|
||||
|
||||
* reports redundant downloads to tracker, fixed downloaded calculation to
|
||||
be more stable when not including redundant. Improved redundant data accounting
|
||||
to be more accurate
|
||||
* fixed bugs in http seed connection and added unit test for it
|
||||
* fixed error reporting when fallocate fails
|
||||
* deprecate support for separate proxies for separate kinds of connections
|
||||
|
|
|
@ -79,6 +79,11 @@ namespace libtorrent
|
|||
{
|
||||
tracker_request()
|
||||
: kind(announce_request)
|
||||
, downloaded(-1)
|
||||
, uploaded(-1)
|
||||
, left(-1)
|
||||
, corrupt(0)
|
||||
, redundant(0)
|
||||
, event(none)
|
||||
, key(0)
|
||||
, num_want(0)
|
||||
|
@ -106,6 +111,7 @@ namespace libtorrent
|
|||
size_type uploaded;
|
||||
size_type left;
|
||||
size_type corrupt;
|
||||
size_type redundant;
|
||||
unsigned short listen_port;
|
||||
event_t event;
|
||||
std::string url;
|
||||
|
|
|
@ -138,8 +138,8 @@ namespace libtorrent
|
|||
char str[1024];
|
||||
const bool stats = tracker_req().send_stats;
|
||||
snprintf(str, sizeof(str), "&peer_id=%s&port=%d&uploaded=%"PRId64
|
||||
"&downloaded=%"PRId64"&left=%"PRId64"&corrupt=%"PRId64"&compact=1"
|
||||
"&numwant=%d&key=%x&no_peer_id=1"
|
||||
"&downloaded=%"PRId64"&left=%"PRId64"&corrupt=%"PRId64"&redundant=%"PRId64
|
||||
"&compact=1&numwant=%d&key=%x&no_peer_id=1"
|
||||
, escape_string((const char*)&tracker_req().pid[0], 20).c_str()
|
||||
// the i2p tracker seems to verify that the port is not 0,
|
||||
// even though it ignores it otherwise
|
||||
|
@ -148,6 +148,7 @@ namespace libtorrent
|
|||
, stats ? tracker_req().downloaded : 0
|
||||
, stats ? tracker_req().left : 0
|
||||
, stats ? tracker_req().corrupt : 0
|
||||
, stats ? tracker_req().redundant: 0
|
||||
, tracker_req().num_want
|
||||
, tracker_req().key);
|
||||
url += str;
|
||||
|
|
|
@ -3289,7 +3289,19 @@ namespace libtorrent
|
|||
if (t)
|
||||
{
|
||||
// make sure we keep all the stats!
|
||||
if (!m_ignore_stats) t->add_stats(statistics());
|
||||
if (!m_ignore_stats)
|
||||
{
|
||||
t->add_stats(statistics());
|
||||
|
||||
// report any partially received payload as redundant
|
||||
boost::optional<piece_block_progress> pbp = downloading_piece_progress();
|
||||
if (pbp
|
||||
&& pbp->bytes_downloaded > 0
|
||||
&& pbp->bytes_downloaded < pbp->full_block_bytes)
|
||||
{
|
||||
t->add_redundant_bytes(pbp->bytes_downloaded);
|
||||
}
|
||||
}
|
||||
|
||||
if (t->has_picker())
|
||||
{
|
||||
|
|
|
@ -1449,15 +1449,24 @@ namespace libtorrent
|
|||
tracker_request req;
|
||||
req.info_hash = m_torrent_file->info_hash();
|
||||
req.pid = m_ses.get_peer_id();
|
||||
req.downloaded = m_stat.total_payload_download() - m_total_failed_bytes;
|
||||
req.uploaded = m_stat.total_payload_upload();
|
||||
req.corrupt = m_total_failed_bytes;
|
||||
req.redundant = m_total_redundant_bytes;
|
||||
|
||||
if (settings().report_true_downloaded)
|
||||
{
|
||||
req.downloaded = m_stat.total_payload_download() - m_total_failed_bytes;
|
||||
req.left = bytes_left();
|
||||
}
|
||||
else
|
||||
{
|
||||
req.downloaded = quantized_bytes_done();
|
||||
TORRENT_ASSERT(!valid_metadata() || req.downloaded <= m_torrent_file->total_size());
|
||||
req.left = valid_metadata() ? m_torrent_file->total_size() - req.downloaded : -1;
|
||||
}
|
||||
if (req.left == -1) req.left = 16*1024;
|
||||
|
||||
// exclude redundant bytes if we should
|
||||
if (!settings().report_true_downloaded)
|
||||
req.downloaded -= m_total_redundant_bytes;
|
||||
TORRENT_ASSERT(req.downloaded >= 0);
|
||||
|
||||
req.event = e;
|
||||
error_code ec;
|
||||
|
@ -6838,6 +6847,8 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(b > 0);
|
||||
m_total_redundant_bytes += b;
|
||||
m_ses.add_redundant_bytes(b);
|
||||
TORRENT_ASSERT(m_total_redundant_bytes + m_total_failed_bytes
|
||||
<= m_stat.total_payload_download());
|
||||
}
|
||||
|
||||
void torrent::add_failed_bytes(int b)
|
||||
|
@ -6845,6 +6856,8 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(b > 0);
|
||||
m_total_failed_bytes += b;
|
||||
m_ses.add_failed_bytes(b);
|
||||
TORRENT_ASSERT(m_total_redundant_bytes + m_total_failed_bytes
|
||||
<= m_stat.total_payload_download());
|
||||
}
|
||||
|
||||
int torrent::num_seeds() const
|
||||
|
|
|
@ -96,10 +96,6 @@ namespace libtorrent
|
|||
void web_peer_connection::disconnect(error_code const& ec, int error)
|
||||
{
|
||||
boost::shared_ptr<torrent> t = associated_torrent().lock();
|
||||
|
||||
if (t && m_block_pos)
|
||||
t->add_redundant_bytes(m_block_pos);
|
||||
|
||||
peer_connection::disconnect(ec, error);
|
||||
if (t) t->disconnect_web_seed(this);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue