merged file priority fix from RC_0_16

This commit is contained in:
Arvid Norberg 2013-01-28 04:57:35 +00:00
parent 7223bf17e5
commit 42ee2869b1
3 changed files with 22 additions and 3 deletions

View File

@ -11,6 +11,7 @@
* fix uTP edge case where udp socket buffer fills up
* fix nagle implementation in uTP
* fixed file priority vector-overrun
* fix potential packet allocation alignment issue in utp
* make 'close_redudnant_connections' cover more cases
* set_piece_deadline() also unfilters the piece (if its priority is 0)

View File

@ -1524,6 +1524,9 @@ namespace libtorrent
TORRENT_ASSERT(m_torrent_file->num_files() > 0);
TORRENT_ASSERT(m_torrent_file->total_size() >= 0);
if (m_file_priority.size() > m_torrent_file->num_files())
m_file_priority.resize(m_torrent_file->num_files());
#ifdef TORRENT_USE_OPENSSL
std::string cert = m_torrent_file->ssl_cert();
if (!cert.empty()) init_ssl(cert);
@ -3975,6 +3978,11 @@ namespace libtorrent
TORRENT_ASSERT(index < m_torrent_file->num_files());
TORRENT_ASSERT(index >= 0);
if (index < 0 || index >= m_torrent_file->num_files()) return;
if (m_file_priority.size() <= index)
{
if (prio == 1) return;
m_file_priority.resize(m_torrent_file->num_files(), 1);
}
if (m_file_priority[index] == prio) return;
m_file_priority[index] = prio;
update_piece_priorities();
@ -3988,6 +3996,7 @@ namespace libtorrent
TORRENT_ASSERT(index < m_torrent_file->num_files());
TORRENT_ASSERT(index >= 0);
if (index < 0 || index >= m_torrent_file->num_files()) return 0;
if (m_file_priority.size() <= index) return 1;
return m_file_priority[index];
}
@ -4001,10 +4010,9 @@ namespace libtorrent
return;
}
files->resize(m_torrent_file->num_files());
files->resize(m_torrent_file->num_files(), 1);
TORRENT_ASSERT(m_file_priority.size() <= m_torrent_file->num_files());
std::copy(m_file_priority.begin(), m_file_priority.end(), files->begin());
if (m_file_priority.size() < m_torrent_file->num_files())
std::fill(files->begin() + m_file_priority.size(), files->end(), 1);
}
void torrent::update_piece_priorities()

View File

@ -50,12 +50,22 @@ void test_running_torrent(boost::intrusive_ptr<torrent_info> info, size_type fil
session ses(fingerprint("LT", 0, 1, 0, 0), std::make_pair(48130, 48140), "0.0.0.0", 0);
ses.set_alert_mask(alert::storage_notification);
std::vector<boost::uint8_t> zeroes;
zeroes.resize(1000, 0);
add_torrent_params p;
p.ti = info;
p.save_path = ".";
// make sure we correctly handle the case where we pass in
// more values than there are files
p.file_priorities = &zeroes;
error_code ec;
torrent_handle h = ses.add_torrent(p, ec);
std::vector<int> ones(info->num_files(), 1);
h.prioritize_files(ones);
test_sleep(500);
torrent_status st = h.status();