another pending_bytes fix
This commit is contained in:
parent
fb6130bd95
commit
76db4627f6
|
@ -778,6 +778,10 @@ namespace libtorrent
|
||||||
// the piece requests
|
// the piece requests
|
||||||
std::vector<int> m_requests_in_buffer;
|
std::vector<int> m_requests_in_buffer;
|
||||||
|
|
||||||
|
// the block we're currently receiving. Or
|
||||||
|
// (-1, -1) if we're not receiving one
|
||||||
|
piece_block m_receiving_block;
|
||||||
|
|
||||||
// the number of bytes that the other
|
// the number of bytes that the other
|
||||||
// end has to send us in order to respond
|
// end has to send us in order to respond
|
||||||
// to all outstanding piece requests we
|
// to all outstanding piece requests we
|
||||||
|
|
|
@ -98,6 +98,7 @@ namespace libtorrent
|
||||||
, m_socket(s)
|
, m_socket(s)
|
||||||
, m_remote(endp)
|
, m_remote(endp)
|
||||||
, m_torrent(tor)
|
, m_torrent(tor)
|
||||||
|
, m_receiving_block(-1, -1)
|
||||||
, m_outstanding_bytes(0)
|
, m_outstanding_bytes(0)
|
||||||
, m_queued_time_critical(0)
|
, m_queued_time_critical(0)
|
||||||
, m_num_pieces(0)
|
, m_num_pieces(0)
|
||||||
|
@ -218,6 +219,7 @@ namespace libtorrent
|
||||||
, m_disk_recv_buffer(ses, 0)
|
, m_disk_recv_buffer(ses, 0)
|
||||||
, m_socket(s)
|
, m_socket(s)
|
||||||
, m_remote(endp)
|
, m_remote(endp)
|
||||||
|
, m_receiving_block(-1, -1)
|
||||||
, m_outstanding_bytes(0)
|
, m_outstanding_bytes(0)
|
||||||
, m_queued_time_critical(0)
|
, m_queued_time_critical(0)
|
||||||
, m_num_pieces(0)
|
, m_num_pieces(0)
|
||||||
|
@ -1738,6 +1740,7 @@ namespace libtorrent
|
||||||
boost::shared_ptr<torrent> t = associated_torrent().lock();
|
boost::shared_ptr<torrent> t = associated_torrent().lock();
|
||||||
TORRENT_ASSERT(t);
|
TORRENT_ASSERT(t);
|
||||||
piece_block b(r.piece, r.start / t->block_size());
|
piece_block b(r.piece, r.start / t->block_size());
|
||||||
|
m_receiving_block = b;
|
||||||
|
|
||||||
if (!verify_piece(r))
|
if (!verify_piece(r))
|
||||||
{
|
{
|
||||||
|
@ -1836,6 +1839,10 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(!m_disk_recv_buffer);
|
TORRENT_ASSERT(!m_disk_recv_buffer);
|
||||||
TORRENT_ASSERT(m_disk_recv_buffer_size == 0);
|
TORRENT_ASSERT(m_disk_recv_buffer_size == 0);
|
||||||
|
|
||||||
|
// we're not receiving any block right now
|
||||||
|
m_receiving_block.piece_index = -1;
|
||||||
|
m_receiving_block.block_index = -1;
|
||||||
|
|
||||||
#ifdef TORRENT_CORRUPT_DATA
|
#ifdef TORRENT_CORRUPT_DATA
|
||||||
// corrupt all pieces from certain peers
|
// corrupt all pieces from certain peers
|
||||||
if (m_remote.address().is_v4()
|
if (m_remote.address().is_v4()
|
||||||
|
@ -2477,9 +2484,7 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(block_size <= t->block_size());
|
TORRENT_ASSERT(block_size <= t->block_size());
|
||||||
|
|
||||||
// we can't cancel the piece if we've started receiving it
|
// we can't cancel the piece if we've started receiving it
|
||||||
// if m_outstsanding_bytes is less than the block size,
|
if (m_receiving_block == b) continue;
|
||||||
// it means we have received parts of it already
|
|
||||||
if (m_outstanding_bytes < block_size) break;
|
|
||||||
|
|
||||||
peer_request r;
|
peer_request r;
|
||||||
r.piece = b.piece_index;
|
r.piece = b.piece_index;
|
||||||
|
|
Loading…
Reference in New Issue