mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-02 06:36:15 +00:00
Sync lt 1825
This commit is contained in:
parent
6dff50c3f5
commit
58a0506b98
@ -779,6 +779,10 @@ namespace libtorrent
|
|||||||
|
|
||||||
// the maximum number of connections for this torrent
|
// the maximum number of connections for this torrent
|
||||||
int m_max_connections;
|
int m_max_connections;
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
bool m_files_checked;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
typedef std::list<boost::shared_ptr<torrent_plugin> > extension_list_t;
|
typedef std::list<boost::shared_ptr<torrent_plugin> > extension_list_t;
|
||||||
|
@ -80,10 +80,10 @@ namespace libtorrent
|
|||||||
TORRENT_ASSERT(m_blocks_in_last_piece <= m_blocks_per_piece);
|
TORRENT_ASSERT(m_blocks_in_last_piece <= m_blocks_per_piece);
|
||||||
|
|
||||||
// allocate the piece_map to cover all pieces
|
// allocate the piece_map to cover all pieces
|
||||||
// and make them invalid (as if though we already had every piece)
|
// and make them invalid (as if we don't have a single piece)
|
||||||
std::fill(m_piece_map.begin(), m_piece_map.end()
|
std::fill(m_piece_map.begin(), m_piece_map.end()
|
||||||
, piece_pos(0, piece_pos::we_have_index));
|
, piece_pos(0, 0));
|
||||||
m_num_have = m_piece_map.size();
|
m_num_have = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// pieces is a bitmask with the pieces we have
|
// pieces is a bitmask with the pieces we have
|
||||||
@ -92,20 +92,29 @@ namespace libtorrent
|
|||||||
, std::vector<downloading_piece> const& unfinished
|
, std::vector<downloading_piece> const& unfinished
|
||||||
, std::vector<int>& verify_pieces)
|
, std::vector<int>& verify_pieces)
|
||||||
{
|
{
|
||||||
|
TORRENT_PIECE_PICKER_INVARIANT_CHECK;
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
m_files_checked_called = true;
|
m_files_checked_called = true;
|
||||||
#endif
|
#endif
|
||||||
for (std::vector<bool>::const_iterator i = pieces.begin();
|
for (std::vector<bool>::const_iterator i = pieces.begin();
|
||||||
i != pieces.end(); ++i)
|
i != pieces.end(); ++i)
|
||||||
{
|
{
|
||||||
if (*i) continue;
|
|
||||||
int index = static_cast<int>(i - pieces.begin());
|
int index = static_cast<int>(i - pieces.begin());
|
||||||
m_piece_map[index].index = 0;
|
piece_pos& p = m_piece_map[index];
|
||||||
--m_num_have;
|
if (*i)
|
||||||
if (m_piece_map[index].filtered())
|
|
||||||
{
|
{
|
||||||
++m_num_filtered;
|
++m_num_have;
|
||||||
--m_num_have_filtered;
|
p.set_have();
|
||||||
|
if (p.filtered())
|
||||||
|
{
|
||||||
|
++m_num_have_filtered;
|
||||||
|
TORRENT_ASSERT(m_num_filtered > 0);
|
||||||
|
--m_num_filtered;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
p.index = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,6 +292,9 @@ namespace libtorrent
|
|||||||
void piece_picker::check_invariant(const torrent* t) const
|
void piece_picker::check_invariant(const torrent* t) const
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(sizeof(piece_pos) == 4);
|
TORRENT_ASSERT(sizeof(piece_pos) == 4);
|
||||||
|
TORRENT_ASSERT(m_num_have >= 0);
|
||||||
|
TORRENT_ASSERT(m_num_have_filtered >= 0);
|
||||||
|
TORRENT_ASSERT(m_num_filtered >= 0);
|
||||||
|
|
||||||
TORRENT_ASSERT(m_piece_info.empty() || m_piece_info[0].empty());
|
TORRENT_ASSERT(m_piece_info.empty() || m_piece_info[0].empty());
|
||||||
|
|
||||||
|
@ -204,6 +204,9 @@ namespace libtorrent
|
|||||||
, m_max_connections((std::numeric_limits<int>::max)())
|
, m_max_connections((std::numeric_limits<int>::max)())
|
||||||
, m_policy(this)
|
, m_policy(this)
|
||||||
{
|
{
|
||||||
|
#ifndef NDEBUG
|
||||||
|
m_files_checked = false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
torrent::torrent(
|
torrent::torrent(
|
||||||
@ -263,6 +266,9 @@ namespace libtorrent
|
|||||||
, m_max_connections((std::numeric_limits<int>::max)())
|
, m_max_connections((std::numeric_limits<int>::max)())
|
||||||
, m_policy(this)
|
, m_policy(this)
|
||||||
{
|
{
|
||||||
|
#ifndef NDEBUG
|
||||||
|
m_files_checked = false;
|
||||||
|
#endif
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
if (name) m_name.reset(new std::string(name));
|
if (name) m_name.reset(new std::string(name));
|
||||||
@ -2521,6 +2527,9 @@ namespace libtorrent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifndef NDEBUG
|
||||||
|
m_files_checked = true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
alert_manager& torrent::alerts() const
|
alert_manager& torrent::alerts() const
|
||||||
@ -2658,7 +2667,7 @@ namespace libtorrent
|
|||||||
complete = false;
|
complete = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (complete)
|
if (complete && m_files_checked)
|
||||||
{
|
{
|
||||||
disk_io_job ret = m_ses.m_disk_thread.find_job(
|
disk_io_job ret = m_ses.m_disk_thread.find_job(
|
||||||
m_owning_storage, -1, i->index);
|
m_owning_storage, -1, i->index);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user