simplified the piece picker by initializing it properly in its constructor. Removed natpmp reporting port map success when removing mappings. fix where incoming connections before the files were completely checked would cause an assert.
This commit is contained in:
@@ -52,7 +52,9 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
namespace libtorrent
|
||||
{
|
||||
|
||||
piece_picker::piece_picker(int blocks_per_piece, int total_num_blocks)
|
||||
piece_picker::piece_picker(int blocks_per_piece, int total_num_blocks
|
||||
, std::vector<bool> const& pieces
|
||||
, std::vector<downloading_piece> const& unfinished)
|
||||
: m_piece_info(2)
|
||||
, m_piece_map((total_num_blocks + blocks_per_piece-1) / blocks_per_piece)
|
||||
, m_num_filtered(0)
|
||||
@@ -61,9 +63,6 @@ namespace libtorrent
|
||||
{
|
||||
assert(blocks_per_piece > 0);
|
||||
assert(total_num_blocks >= 0);
|
||||
#ifndef NDEBUG
|
||||
m_files_checked_called = false;
|
||||
#endif
|
||||
|
||||
// the piece index is stored in 20 bits, which limits the allowed
|
||||
// number of pieces somewhat
|
||||
@@ -82,16 +81,8 @@ namespace libtorrent
|
||||
// and make them invalid (as if though we already had every piece)
|
||||
std::fill(m_piece_map.begin(), m_piece_map.end()
|
||||
, piece_pos(0, piece_pos::we_have_index));
|
||||
}
|
||||
|
||||
// pieces is a bitmask with the pieces we have
|
||||
void piece_picker::files_checked(
|
||||
const std::vector<bool>& pieces
|
||||
, const std::vector<downloading_piece>& unfinished)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
m_files_checked_called = true;
|
||||
#endif
|
||||
|
||||
for (std::vector<bool>::const_iterator i = pieces.begin();
|
||||
i != pieces.end(); ++i)
|
||||
{
|
||||
@@ -126,6 +117,7 @@ namespace libtorrent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void piece_picker::set_sequenced_download_threshold(
|
||||
@@ -376,7 +368,6 @@ namespace libtorrent
|
||||
{
|
||||
assert(priority > 0);
|
||||
assert(elem_index >= 0);
|
||||
assert(m_files_checked_called);
|
||||
|
||||
assert(int(m_piece_info.size()) > priority);
|
||||
assert(int(m_piece_info[priority].size()) > elem_index);
|
||||
@@ -532,7 +523,6 @@ namespace libtorrent
|
||||
|
||||
assert(index >= 0);
|
||||
assert(index < (int)m_piece_map.size());
|
||||
assert(m_files_checked_called);
|
||||
|
||||
assert(m_piece_map[index].downloading == 1);
|
||||
|
||||
@@ -554,7 +544,6 @@ namespace libtorrent
|
||||
// TORRENT_PIECE_PICKER_INVARIANT_CHECK;
|
||||
assert(i >= 0);
|
||||
assert(i < (int)m_piece_map.size());
|
||||
assert(m_files_checked_called);
|
||||
|
||||
piece_pos& p = m_piece_map[i];
|
||||
int index = p.index;
|
||||
@@ -587,7 +576,6 @@ namespace libtorrent
|
||||
{
|
||||
// TORRENT_PIECE_PICKER_INVARIANT_CHECK;
|
||||
|
||||
assert(m_files_checked_called);
|
||||
assert(i >= 0);
|
||||
assert(i < (int)m_piece_map.size());
|
||||
|
||||
@@ -754,7 +742,6 @@ namespace libtorrent
|
||||
TORRENT_PIECE_PICKER_INVARIANT_CHECK;
|
||||
assert(num_blocks > 0);
|
||||
assert(pieces.size() == m_piece_map.size());
|
||||
assert(m_files_checked_called);
|
||||
|
||||
// free refers to pieces that are free to download, no one else
|
||||
// is downloading them.
|
||||
|
Reference in New Issue
Block a user