fixes for torrents with smaller pieces than 16kB
This commit is contained in:
@@ -164,7 +164,7 @@ boost::intrusive_ptr<T> clone_ptr(boost::intrusive_ptr<T> const& ptr)
|
||||
return boost::intrusive_ptr<T>(new T(*ptr));
|
||||
}
|
||||
|
||||
boost::intrusive_ptr<torrent_info> create_torrent(std::ostream* file)
|
||||
boost::intrusive_ptr<torrent_info> create_torrent(std::ostream* file, int piece_size)
|
||||
{
|
||||
char const* tracker_url = "http://non-existent-name.com/announce";
|
||||
|
||||
@@ -173,10 +173,10 @@ boost::intrusive_ptr<torrent_info> create_torrent(std::ostream* file)
|
||||
file_storage fs;
|
||||
int total_size = 2 * 1024 * 1024;
|
||||
fs.add_file(path("temporary"), total_size);
|
||||
libtorrent::create_torrent t(fs, 16 * 1024);
|
||||
libtorrent::create_torrent t(fs, piece_size);
|
||||
t.add_tracker(tracker_url);
|
||||
|
||||
std::vector<char> piece(16 * 1024);
|
||||
std::vector<char> piece(piece_size);
|
||||
for (int i = 0; i < int(piece.size()); ++i)
|
||||
piece[i] = (i % 26) + 'A';
|
||||
|
||||
@@ -204,7 +204,7 @@ boost::intrusive_ptr<torrent_info> create_torrent(std::ostream* file)
|
||||
boost::tuple<torrent_handle, torrent_handle, torrent_handle>
|
||||
setup_transfer(session* ses1, session* ses2, session* ses3
|
||||
, bool clear_files, bool use_metadata_transfer, bool connect_peers
|
||||
, std::string suffix)
|
||||
, std::string suffix, int piece_size)
|
||||
{
|
||||
using namespace boost::filesystem;
|
||||
|
||||
@@ -218,7 +218,7 @@ setup_transfer(session* ses1, session* ses2, session* ses3
|
||||
|
||||
create_directory("./tmp1" + suffix);
|
||||
std::ofstream file(("./tmp1" + suffix + "/temporary").c_str());
|
||||
boost::intrusive_ptr<torrent_info> t = ::create_torrent(&file);
|
||||
boost::intrusive_ptr<torrent_info> t = ::create_torrent(&file, piece_size);
|
||||
file.close();
|
||||
if (clear_files)
|
||||
{
|
||||
|
@@ -10,13 +10,13 @@ void print_alerts(libtorrent::session& ses, char const* name
|
||||
, bool allow_no_torrents = false);
|
||||
void test_sleep(int millisec);
|
||||
|
||||
boost::intrusive_ptr<libtorrent::torrent_info> create_torrent(std::ostream* file = 0);
|
||||
boost::intrusive_ptr<libtorrent::torrent_info> create_torrent(std::ostream* file = 0, int piece_size = 16 * 1024);
|
||||
|
||||
boost::tuple<libtorrent::torrent_handle, libtorrent::torrent_handle
|
||||
, libtorrent::torrent_handle>
|
||||
setup_transfer(libtorrent::session* ses1, libtorrent::session* ses2
|
||||
, libtorrent::session* ses3, bool clear_files, bool use_metadata_transfer = true
|
||||
, bool connect = true, std::string suffix = "");
|
||||
, bool connect = true, std::string suffix = "", int piece_size = 16 * 1024);
|
||||
|
||||
void start_web_server(int port, bool ssl = false);
|
||||
void stop_web_server(int port);
|
||||
|
@@ -54,7 +54,8 @@ void test_swarm()
|
||||
torrent_handle tor2;
|
||||
torrent_handle tor3;
|
||||
|
||||
boost::tie(tor1, tor2, tor3) = setup_transfer(&ses1, &ses2, &ses3, true, false, true, "_swarm");
|
||||
// test using piece sizes smaller than 16kB
|
||||
boost::tie(tor1, tor2, tor3) = setup_transfer(&ses1, &ses2, &ses3, true, false, true, "_swarm", 8 * 1024);
|
||||
|
||||
float sum_dl_rate2 = 0.f;
|
||||
float sum_dl_rate3 = 0.f;
|
||||
|
Reference in New Issue
Block a user