fix bug in piece picker where set_piece_priority would return false even though the piece filter changed and updated test_transfer to catch it

This commit is contained in:
Arvid Norberg 2008-08-19 07:11:17 +00:00
parent 9266afe5f5
commit 893e9f2af6
2 changed files with 34 additions and 1 deletions

View File

@ -1099,7 +1099,7 @@ namespace libtorrent
p.piece_priority = new_piece_priority;
int new_priority = p.priority(this);
if (prev_priority == new_priority) return false;
if (prev_priority == new_priority) return ret;
TORRENT_ASSERT(prev_priority < int(m_priority_boundries.size()));

View File

@ -180,6 +180,39 @@ void test_transfer()
TEST_CHECK(!tor2.is_seed());
std::fill(priorities.begin(), priorities.end(), 1);
tor2.prioritize_pieces(priorities);
std::cout << "setting priorities to 1" << std::endl;
for (int i = 0; i < 130; ++i)
{
print_alerts(ses1, "ses1");
print_alerts(ses2, "ses2");
torrent_status st1 = tor1.status();
torrent_status st2 = tor2.status();
std::cerr
<< "\033[32m" << int(st1.download_payload_rate / 1000.f) << "kB/s "
<< "\033[33m" << int(st1.upload_payload_rate / 1000.f) << "kB/s "
<< "\033[0m" << int(st1.progress * 100) << "% "
<< st1.num_peers
<< ": "
<< "\033[32m" << int(st2.download_payload_rate / 1000.f) << "kB/s "
<< "\033[31m" << int(st2.upload_payload_rate / 1000.f) << "kB/s "
<< "\033[0m" << int(st2.progress * 100) << "% "
<< st2.num_peers
<< std::endl;
if (tor2.is_finished()) break;
TEST_CHECK(st1.state == torrent_status::seeding);
TEST_CHECK(st2.state == torrent_status::downloading);
test_sleep(1000);
}
TEST_CHECK(tor2.is_seed());
}
int test_main()