forked from premiere/premiere-libtorrent
optimize some invariant checks and make test_utp shorted, to complete much faster
This commit is contained in:
parent
a8ac369584
commit
416d064489
|
@ -49,7 +49,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS || TORRENT_DISK_STATS
|
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS || TORRENT_DISK_STATS
|
||||||
#include <map>
|
#include <boost/unordered_map.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
|
@ -129,8 +129,8 @@ namespace libtorrent
|
||||||
public:
|
public:
|
||||||
void rename_buffer(char* buf, char const* category);
|
void rename_buffer(char* buf, char const* category);
|
||||||
protected:
|
protected:
|
||||||
std::map<std::string, int> m_categories;
|
boost::unordered_map<std::string, int> m_categories;
|
||||||
std::map<char*, std::string> m_buf_to_category;
|
boost::unordered_map<char*, std::string> m_buf_to_category;
|
||||||
std::ofstream m_log;
|
std::ofstream m_log;
|
||||||
private:
|
private:
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -5883,6 +5883,7 @@ namespace libtorrent
|
||||||
// num_requests[i->block].peers.push_back(&p);
|
// num_requests[i->block].peers.push_back(&p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
piece_picker::downloading_piece last_piece;
|
||||||
for (std::map<piece_block, peer_count_t>::iterator i = num_requests.begin()
|
for (std::map<piece_block, peer_count_t>::iterator i = num_requests.begin()
|
||||||
, end(num_requests.end()); i != end; ++i)
|
, end(num_requests.end()); i != end; ++i)
|
||||||
{
|
{
|
||||||
|
@ -5893,12 +5894,18 @@ namespace libtorrent
|
||||||
int count_with_nowant = pc.num_peers_with_nowant;
|
int count_with_nowant = pc.num_peers_with_nowant;
|
||||||
(void)count_with_timeouts;
|
(void)count_with_timeouts;
|
||||||
(void)count_with_nowant;
|
(void)count_with_nowant;
|
||||||
int picker_count = t->picker().num_peers(b);
|
if (b.piece_index != last_piece.index)
|
||||||
if (!t->picker().is_downloaded(b))
|
t->picker().piece_info(b.piece_index, last_piece);
|
||||||
|
|
||||||
|
// has b been downloaded?
|
||||||
|
if ((last_piece.finished == 0 && last_piece.writing == 0)
|
||||||
|
|| (last_piece.info && last_piece.info[b.block_index].state >= piece_picker::block_info::state_writing))
|
||||||
|
{
|
||||||
|
int picker_count = t->picker().num_peers(b);
|
||||||
TORRENT_ASSERT(picker_count == count);
|
TORRENT_ASSERT(picker_count == count);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef TORRENT_EXPENSIVE_INVARIANT_CHECKS
|
|
||||||
if (m_peer_info && type() == bittorrent_connection)
|
if (m_peer_info && type() == bittorrent_connection)
|
||||||
{
|
{
|
||||||
policy::const_iterator i = t->get_policy().begin_peer();
|
policy::const_iterator i = t->get_policy().begin_peer();
|
||||||
|
@ -5909,7 +5916,6 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
TORRENT_ASSERT(i != end);
|
TORRENT_ASSERT(i != end);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (t->has_picker() && !t->is_aborted())
|
if (t->has_picker() && !t->is_aborted())
|
||||||
{
|
{
|
||||||
// make sure that pieces that have completed the download
|
// make sure that pieces that have completed the download
|
||||||
|
@ -5930,17 +5936,6 @@ namespace libtorrent
|
||||||
complete = false;
|
complete = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
// this invariant is not valid anymore since the completion event
|
|
||||||
// might be queued in the io service
|
|
||||||
if (complete && !piece_failed)
|
|
||||||
{
|
|
||||||
disk_io_job ret = m_ses.m_disk_thread.find_job(
|
|
||||||
&t->filesystem(), -1, i->index);
|
|
||||||
TORRENT_ASSERT(ret.action == disk_io_job::hash || ret.action == disk_io_job::write);
|
|
||||||
TORRENT_ASSERT(ret.piece == i->index);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ namespace libtorrent
|
||||||
void piece_picker::piece_info(int index, piece_picker::downloading_piece& st) const
|
void piece_picker::piece_info(int index, piece_picker::downloading_piece& st) const
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_EXPENSIVE_INVARIANT_CHECKS
|
#ifdef TORRENT_EXPENSIVE_INVARIANT_CHECKS
|
||||||
TORRENT_PIECE_PICKER_INVARIANT_CHECK;
|
// TORRENT_PIECE_PICKER_INVARIANT_CHECK;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TORRENT_ASSERT(index >= 0);
|
TORRENT_ASSERT(index >= 0);
|
||||||
|
@ -153,7 +153,7 @@ namespace libtorrent
|
||||||
std::vector<downloading_piece>::const_iterator piece = find_dl_piece(index);
|
std::vector<downloading_piece>::const_iterator piece = find_dl_piece(index);
|
||||||
TORRENT_ASSERT(piece != m_downloads.end());
|
TORRENT_ASSERT(piece != m_downloads.end());
|
||||||
st = *piece;
|
st = *piece;
|
||||||
st.info = 0;
|
// st.info = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
st.info = 0;
|
st.info = 0;
|
||||||
|
|
|
@ -100,7 +100,7 @@ void test_transfer()
|
||||||
|
|
||||||
create_directory("./tmp1_utp", ec);
|
create_directory("./tmp1_utp", ec);
|
||||||
std::ofstream file("./tmp1_utp/temporary");
|
std::ofstream file("./tmp1_utp/temporary");
|
||||||
boost::intrusive_ptr<torrent_info> t = ::create_torrent(&file, 512 * 1024, 20, false);
|
boost::intrusive_ptr<torrent_info> t = ::create_torrent(&file, 128 * 1024, 6, false);
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
// for performance testing
|
// for performance testing
|
||||||
|
|
Loading…
Reference in New Issue