fixed web seed test to work with invariant checks turned on and fixed error reporting when receiving an unexpected responce for http seeds

This commit is contained in:
Arvid Norberg 2010-10-30 19:45:50 +00:00
parent a76570b563
commit 0773644a4e
5 changed files with 19 additions and 8 deletions

View File

@ -333,6 +333,14 @@ namespace libtorrent
disconnect(errors::no_content_length, 2);
return;
}
if (m_response_left != front_request.length)
{
m_statistics.received_bytes(0, bytes_transferred);
// we should not try this server again.
t->remove_web_seed(this);
disconnect(errors::invalid_range, 2);
return;
}
if (payload > m_response_left) payload = m_response_left;
m_body_start = m_parser.body_start();
m_response_left -= payload;

View File

@ -2860,7 +2860,9 @@ ret:
{
TORRENT_ASSERT(num_slots > 0);
#ifdef TORRENT_EXPENSIVE_INVARIANT_CHECKS
INVARIANT_CHECK;
#endif
TORRENT_ASSERT(!m_unallocated_slots.empty());
TORRENT_ASSERT(m_storage_mode == storage_mode_compact);
@ -2869,8 +2871,6 @@ ret:
for (int i = 0; i < num_slots && !m_unallocated_slots.empty(); ++i)
{
// INVARIANT_CHECK;
int pos = m_unallocated_slots.front();
TORRENT_ASSERT(m_slot_to_piece[pos] == unallocated);
TORRENT_ASSERT(m_piece_to_slot[pos] != pos);

View File

@ -3418,7 +3418,6 @@ namespace libtorrent
return;
}
web->resolving = true;
proxy_settings const& ps = m_ses.proxy();
if (ps.type == proxy_settings::http
|| ps.type == proxy_settings::http_pw)
@ -3436,6 +3435,7 @@ namespace libtorrent
}
else
{
web->resolving = true;
tcp::resolver::query q(hostname, to_string(port).elems);
m_ses.m_host_resolver.async_resolve(q,
boost::bind(&torrent::on_name_lookup, shared_from_this(), _1, _2, web
@ -3501,6 +3501,7 @@ namespace libtorrent
return;
}
web->resolving = true;
tcp::resolver::query q(hostname, to_string(port).elems);
m_ses.m_host_resolver.async_resolve(q,
boost::bind(&torrent::on_name_lookup, shared_from_this(), _1, _2, web, a));

View File

@ -869,12 +869,12 @@ void web_server_thread(int* port, bool ssl, bool chunked)
else
{
range_start = 0;
// assume piece size of 16
range_end = 16-1;
// assume piece size of 64kiB
range_end = 64*1024-1;
}
int size = range_end - range_start + 1;
boost::uint64_t off = idx * 16 + range_start;
boost::uint64_t off = idx * 64 * 1024 + range_start;
std::vector<char> file_buf;
int res = load_file("./tmp1_web_seed/seed", file_buf);

View File

@ -195,6 +195,7 @@ int run_suite(char const* protocol, bool test_url_seed, bool chunked_encoding)
file_storage fs;
std::srand(10);
int piece_size = 16;
if (test_url_seed)
{
int file_sizes[] =
@ -214,7 +215,8 @@ int run_suite(char const* protocol, bool test_url_seed, bool chunked_encoding)
}
else
{
char random_data[10000];
piece_size = 64 * 1024;
char random_data[64 * 1024 * 50];
std::generate(random_data, random_data + sizeof(random_data), &std::rand);
save_file("./tmp1_web_seed/seed", random_data, sizeof(random_data));
fs.add_file("seed", sizeof(random_data));
@ -222,7 +224,7 @@ int run_suite(char const* protocol, bool test_url_seed, bool chunked_encoding)
int port = start_web_server(strcmp(protocol, "https") == 0, chunked_encoding);
libtorrent::create_torrent t(fs, 16, 0, libtorrent::create_torrent::calculate_file_hashes);
libtorrent::create_torrent t(fs, piece_size, 0, libtorrent::create_torrent::calculate_file_hashes);
char tmp[512];
if (test_url_seed)
{