*** 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 enum
{ {
// the limits of the download queue size // the limits of the download queue size
max_request_queue = 100, max_request_queue = 48,
min_request_queue = 2, min_request_queue = 2,
// the amount of free upload allowed before // the amount of free upload allowed before
@@ -90,7 +90,7 @@ namespace
const int queue_time = 5; // seconds const int queue_time = 5; // seconds
// (if the latency is more than this, the download will stall) // (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) // 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)); 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; 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 // let the readable clients receive data
for (std::vector<boost::shared_ptr<socket> >::iterator i = readable_clients.begin(); for (std::vector<boost::shared_ptr<socket> >::iterator i = readable_clients.begin();
i != readable_clients.end(); i != readable_clients.end(); ++i)
++i)
{ {
// special case for m_listen_socket socket // special case for m_listen_socket socket
if (*i == m_listen_socket) if (*i == m_listen_socket)

View File

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