*** empty log message ***

This commit is contained in:
Arvid Norberg 2005-07-04 16:27:14 +00:00
parent 6f698e98a5
commit aa57fde0db
3 changed files with 52 additions and 64 deletions

View File

@ -65,7 +65,7 @@ namespace
enum
{
// the limits of the download queue size
max_request_queue = 100,
max_request_queue = 48,
min_request_queue = 2,
// the amount of free upload allowed before
@ -90,7 +90,7 @@ namespace
const int queue_time = 5; // seconds
// (if the latency is more than this, the download will stall)
// so, the queue size is 5 * down_rate / 16 kiB (16 kB is the size of each request)
// the minimum request size is 2 and the maximum is 100
// the minimum request size is 2 and the maximum is 48
int desired_queue_size = static_cast<int>(queue_time * c.statistics().download_rate() / (16 * 1024));
if (desired_queue_size > max_request_queue) desired_queue_size = max_request_queue;

View File

@ -500,8 +500,7 @@ namespace libtorrent { namespace detail
// let the readable clients receive data
for (std::vector<boost::shared_ptr<socket> >::iterator i = readable_clients.begin();
i != readable_clients.end();
++i)
i != readable_clients.end(); ++i)
{
// special case for m_listen_socket socket
if (*i == m_listen_socket)

View File

@ -632,81 +632,70 @@ namespace libtorrent
m_picker->filtered_pieces(bitmask);
}
//suggest using this function on filter single file after the downloading progress
//that is after called filter_files function
//or tmp to change a single file filter policy
//idea from Arvid and MooPolice
//todo refactoring and improving the function body
void torrent::filter_file(int index, bool filter)
{
// this call is only valid on torrents with metadata
if (!valid_metadata()) return;
try
{
__int64 position = 0, start, piece_length;
int start_piece, end_piece;
if (0 < m_torrent_file.num_pieces())
{
piece_length = m_torrent_file.piece_length();
assert(index < m_torrent_file.num_files());
assert(index >= 0);
for (int i = 0;i < index;++i)
{
start = position;
position += m_torrent_file.file_at(i).size;
}
entry::integer_type start_position = 0;
int start_piece_index = 0;
int end_piece_index = 0;
start_piece = (int)(start / piece_length);
end_piece = (int)(position / piece_length);
// TODO: just skipping the first and last piece is not a good idea.
// they should only be skipped if there are files that are wanted
// that span those pieces. Maybe this function should be removed.
for (int i = 0; i < index; ++i)
start_position += m_torrent_file.file_at(i).size;
for (int filter_index = start_piece;filter_index <= end_piece;++filter_index)
{
filter_piece(filter_index, filter);
}
}
}
catch (...)
{
}
start_position = start_position + 1;
start_piece_index = start_position / m_torrent_file.piece_length();
end_piece_index = start_piece_index + m_torrent_file.file_at(index).size/(m_torrent_file.piece_length());
for(int i = start_piece_index; i < end_piece_index; ++i)
filter_piece(i, filter);
}
//suggest using this function on filter all files of a torrent file
//suggest using this functon as the global static filter policy of a torrent file
void torrent::filter_files(std::vector<bool> const& bitmask)
{
// this call is only valid on torrents with metadata
if (!valid_metadata()) return;
try
{
__int64 position = 0, start, piece_length;
int start_piece, end_piece;
if (0 < m_torrent_file.num_pieces())
{
piece_length = m_torrent_file.piece_length();
std::vector<bool> vector_filter_files(m_torrent_file.num_pieces(), false);
for (int i=0;i<bitmask.size();i++)
{
start = position;
position += m_torrent_file.file_at(i).size;
// is the file selected for undownload?
if (true == bitmask[i])
{
// mark all pieces of the file as filtered
start_piece = (int)(start / piece_length);
end_piece = (int)(position / piece_length);
// if one piece spawns several files, we might
// come here several times with the same start_piece, end_piece
for (int index = start_piece;index<=end_piece;index++)
{
vector_filter_files[index] = true;
}
}
}
filter_pieces(vector_filter_files);
}
}
catch (...)
{
}
try
{
entry::integer_type position = 0;
if (m_torrent_file.num_pieces())
{
int piece_length = m_torrent_file.piece_length();
// mark all pieces as filtered, then clear the bits for files
// that should be downloaded
std::vector<bool> piece_filter(m_torrent_file.num_pieces(), true);
for (int i = 0; i < bitmask.size(); ++i)
{
entry::integer_type start = position;
position += m_torrent_file.file_at(i).size;
// is the file selected for download?
if (!bitmask[i])
{
// mark all pieces of the file as downloadable
int start_piece = int(start / piece_length);
int last_piece = int(position / piece_length);
// if one piece spans several files, we might
// come here several times with the same start_piece, end_piece
std::fill(piece_filter.begin() + start_piece, piece_filter.begin()
+ last_piece + 1, false);
}
}
filter_pieces(piece_filter);
}
}
catch (std::exception) {}
}
void torrent::replace_trackers(std::vector<announce_entry> const& urls)