added some asserts and updated changelog
This commit is contained in:
parent
400aeaa347
commit
9e27e33c99
|
@ -1,3 +1,4 @@
|
||||||
|
* fixed bug in DHT code which would send incorrect announce messages.
|
||||||
* fixed bug where the http header parser was case sensitive to the header
|
* fixed bug where the http header parser was case sensitive to the header
|
||||||
names.
|
names.
|
||||||
* Implemented an optmization which frees the piece_picker once a torrent
|
* Implemented an optmization which frees the piece_picker once a torrent
|
||||||
|
|
|
@ -1129,6 +1129,19 @@ namespace libtorrent
|
||||||
assert(verified);
|
assert(verified);
|
||||||
t->completed();
|
t->completed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
|
||||||
|
size_type total_done, total_wanted;
|
||||||
|
boost::tie(total_done, total_wanted) = t->bytes_done();
|
||||||
|
if (t->is_seed())
|
||||||
|
assert(total_done == t->torrent_file().total_size());
|
||||||
|
else
|
||||||
|
assert(total_done != t->torrent_file().total_size());
|
||||||
|
|
||||||
|
t->check_invariant();
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
|
||||||
|
@ -1481,8 +1494,11 @@ namespace libtorrent
|
||||||
t->remove_peer(this);
|
t->remove_peer(this);
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
assert(m_download_queue.empty());
|
if (!t->is_seed())
|
||||||
assert(m_request_queue.empty());
|
{
|
||||||
|
assert(m_download_queue.empty());
|
||||||
|
assert(m_request_queue.empty());
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
m_torrent.reset();
|
m_torrent.reset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -729,7 +729,14 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
int corr = 0;
|
int corr = 0;
|
||||||
if (m_have_pieces[i->index]) continue;
|
if (m_have_pieces[i->index]) continue;
|
||||||
// assert(!m_have_pieces[i->index]);
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
for (std::vector<piece_picker::downloading_piece>::const_iterator j = boost::next(i);
|
||||||
|
j != dl_queue.end(); ++j)
|
||||||
|
{
|
||||||
|
assert(j->index != i->index);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
for (int j = 0; j < blocks_per_piece; ++j)
|
for (int j = 0; j < blocks_per_piece; ++j)
|
||||||
{
|
{
|
||||||
|
@ -785,12 +792,18 @@ namespace libtorrent
|
||||||
if (!m_picker->is_filtered(i->first.piece_index))
|
if (!m_picker->is_filtered(i->first.piece_index))
|
||||||
wanted_done += i->second;
|
wanted_done += i->second;
|
||||||
}
|
}
|
||||||
|
assert(total_done >= wanted_done);
|
||||||
return make_tuple(total_done, wanted_done);
|
return make_tuple(total_done, wanted_done);
|
||||||
}
|
}
|
||||||
|
|
||||||
void torrent::piece_failed(int index)
|
void torrent::piece_failed(int index)
|
||||||
{
|
{
|
||||||
INVARIANT_CHECK;
|
// if the last piece fails the peer connection will still
|
||||||
|
// think that it has received all of it until this function
|
||||||
|
// resets the download queue. So, we cannot do the
|
||||||
|
// invariant check here since it assumes:
|
||||||
|
// (total_done == m_torrent_file.total_size()) => is_seed()
|
||||||
|
// INVARIANT_CHECK;
|
||||||
|
|
||||||
assert(m_storage.get());
|
assert(m_storage.get());
|
||||||
assert(m_picker.get());
|
assert(m_picker.get());
|
||||||
|
@ -1461,6 +1474,8 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
// disconnect all seeds
|
// disconnect all seeds
|
||||||
|
// TODO: should disconnect all peers that have the pieces we have
|
||||||
|
// not just seeds
|
||||||
std::vector<peer_connection*> seeds;
|
std::vector<peer_connection*> seeds;
|
||||||
for (peer_iterator i = m_connections.begin();
|
for (peer_iterator i = m_connections.begin();
|
||||||
i != m_connections.end(); ++i)
|
i != m_connections.end(); ++i)
|
||||||
|
@ -1485,14 +1500,6 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
/*
|
|
||||||
if (alerts().should_post(alert::info))
|
|
||||||
{
|
|
||||||
alerts().post_alert(torrent_complete_alert(
|
|
||||||
get_handle()
|
|
||||||
, "torrent is complete"));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
// make the next tracker request
|
// make the next tracker request
|
||||||
// be a completed-event
|
// be a completed-event
|
||||||
m_event = tracker_request::completed;
|
m_event = tracker_request::completed;
|
||||||
|
@ -1689,7 +1696,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (valid_metadata())
|
if (valid_metadata())
|
||||||
{
|
{
|
||||||
assert(m_have_pieces.size() == m_torrent_file.num_pieces());
|
assert(int(m_have_pieces.size()) == m_torrent_file.num_pieces());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2198,7 +2205,7 @@ namespace libtorrent
|
||||||
else
|
else
|
||||||
st.state = torrent_status::downloading_metadata;
|
st.state = torrent_status::downloading_metadata;
|
||||||
|
|
||||||
// TODO: add e progress member to the torrent that will be used in this case
|
// TODO: add a progress member to the torrent that will be used in this case
|
||||||
// and that may be set by a plugin
|
// and that may be set by a plugin
|
||||||
// if (m_metadata_size == 0) st.progress = 0.f;
|
// if (m_metadata_size == 0) st.progress = 0.f;
|
||||||
// else st.progress = std::min(1.f, m_metadata_progress / (float)m_metadata_size);
|
// else st.progress = std::min(1.f, m_metadata_progress / (float)m_metadata_size);
|
||||||
|
@ -2250,7 +2257,6 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
else if (st.total_wanted_done == st.total_wanted)
|
else if (st.total_wanted_done == st.total_wanted)
|
||||||
{
|
{
|
||||||
assert(!is_seed());
|
|
||||||
assert(st.total_done != m_torrent_file.total_size());
|
assert(st.total_done != m_torrent_file.total_size());
|
||||||
st.state = torrent_status::finished;
|
st.state = torrent_status::finished;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue